-- To permit log backups, alter the database to use the full recovery model
-- before you run the full database backup.
USE master;
GO
ALTER DATABASE ReportServer
SET RECOVERY FULL
-- First back up the database without using the COPY_ONLY argument.
-- This step is needed after you change the recovery model to full.
-- It prevents a 4214 error from occurring.
USE master;
GO
BACKUP DATABASE ReportServer
TO DISK = '<path-to-backup-folder>\ReportServerExtraBackup.bak'
GO
-- If the ReportServerData device doesn't exist yet, create it.
USE master
GO
EXEC sp_addumpdevice 'disk', 'ReportServerData',
'<path-to-backup-folder>\ReportServerData.bak'
-- Create a logical backup device, ReportServerLog.
USE master
GO
EXEC sp_addumpdevice 'disk', 'ReportServerLog',
'<path-to-backup-folder>\ReportServerLog.bak'
-- Back up the full ReportServer database.
BACKUP DATABASE ReportServer
TO ReportServerData
WITH COPY_ONLY
-- Back up the ReportServer log.
BACKUP LOG ReportServer
TO ReportServerLog
WITH COPY_ONLY
-- To permit log backups, alter the database to use the full recovery model
-- before you run the full database backup.
USE master;
GO
ALTER DATABASE ReportServerTempdb
SET RECOVERY FULL
-- First back up the database without using the COPY_ONLY argument.
-- This step is needed after you change the recovery model to full.
-- It prevents a 4214 error from occurring.
USE master;
GO
BACKUP DATABASE ReportServerTempdb
TO DISK = '<path-to-backup-folder>\ReportServerTempdbExtraBackup.bak'
GO
-- If the ReportServerTempDBData device doesn't exist yet, create it.
USE master
GO
EXEC sp_addumpdevice 'disk', 'ReportServerTempDBData',
'<path-to-backup-folder>\ReportServerTempDBData.bak'
-- Create a logical backup device, ReportServerTempDBLog.
USE master
GO
EXEC sp_addumpdevice 'disk', 'ReportServerTempDBLog',
'<path-to-backup-folder>\ReportServerTempDBLog.bak'
-- Back up the full ReportServerTempDB database.
BACKUP DATABASE ReportServerTempDB
TO ReportServerTempDBData
WITH COPY_ONLY
-- Back up the ReportServerTempDB log.
BACKUP LOG ReportServerTempDB
TO ReportServerTempDBLog
WITH COPY_ONLY
使用 RESTORE 和 MOVE 重新定位报表服务器数据库
若要还原数据库,请打开 SQL Server Management Studio,然后在查询窗口中运行以下语句。
-- Restore the report server database and move it to the new instance folder.
RESTORE DATABASE ReportServer
FROM DISK='<path-to-backup-folder>\ReportServerData.bak'
WITH NORECOVERY,
MOVE '<report-server-database-logical-name>' TO
'<path-to-new-data-folder>\ReportServer.mdf',
MOVE '<report-server-database-log-logical-name>' TO
'<path-to-new-data-folder>\ReportServer_Log.ldf';
GO
-- Restore the report server log file to the new instance folder.
RESTORE LOG ReportServer
FROM DISK='<path-to-backup-folder>\ReportServerData.bak'
WITH NORECOVERY, FILE=<report-server-database-log-file-position>,
MOVE '<report-server-database-logical-name>' TO
'<path-to-new-data-folder>\ReportServer.mdf',
MOVE '<report-server-database-log-logical-name>' TO
'<path-to-new-data-folder>\ReportServer_Log.ldf';
GO
-- Restore and move the report server temporary database.
RESTORE DATABASE ReportServerTempdb
FROM DISK='<path-to-backup-folder>\ReportServerTempDBData.bak'
WITH NORECOVERY,
MOVE '<temporary-database-logical-name>' TO
'<path-to-new-data-folder>\ReportServerTempDB.mdf',
MOVE '<temporary-database-log-logical-name>' TO
'<path-to-new-data-folder>\ReportServerTempDB_Log.ldf';
GO
-- Restore the temporary database log file to the new instance folder.
RESTORE LOG ReportServerTempdb
FROM DISK='<path-to-backup-folder>\ReportServerTempDBData.bak'
WITH NORECOVERY, FILE=<temporary-database-log-file-position>,
MOVE '<temporary-database-logical-name>' TO
'<path-to-new-data-folder>\ReportServerTempDB.mdf',
MOVE '<temporary-database-log-logical-name>' TO
'<path-to-new-data-folder>\ReportServerTempDB_Log.ldf';
GO
-- Perform the final restore operation on the report database.
RESTORE DATABASE ReportServer
WITH RECOVERY
GO
-- Perform the final restore operation on the temporary database.
RESTORE DATABASE ReportServerTempDB
WITH RECOVERY
GO
配置报表服务器数据库连接
启动报表服务器配置管理器并打开与报表服务器的连接。
在“数据库”页上,选择“更改数据库” 。
在“更改数据库”页上,选择 现有报表服务器数据库,然后选择“ 下一步”。
对于 服务器名称,请输入现在托管报表服务器数据库的 SQL Server 实例,然后选择“ 测试连接”。
测试连接后,选择“ 下一步”。
对于 报表服务器数据库,请选择要使用的报表服务器数据库,然后选择“ 下一步”。
在“凭据”下,指定报表服务器用于连接到报表服务器数据库的凭据,然后选择“下一步”。
选择“下一步”,然后选择“完成” 。
备注
在 SSRS 安装中,SQL Server 数据库引擎实例必须包含 RSExecRole 角色。 使用报表服务器配置管理器设置报表服务器数据库连接时,会发生角色创建、登录注册和角色分配。 如果使用备用方法(例如rsconfig.exe命令提示符实用工具),则报表服务器未处于工作状态。 在这种情况下,可能需要编写 Windows Management Instrumentation (WMI) 代码才能使报表服务器可用。 有关详细信息,请参阅 访问 Reporting Services WMI 提供程序。