Moving a Report Server Database to Another Computer

You can move the report server databases that are used in a current installation to a SQL Server Database Engine instance that is on a different computer. Both the reportserver and reportservertempdb databases must be moved or copied together. A Reporting Services installation requires both databases; the reportservertempdb database must be related by name to the primary reportserver database you are moving.

Moving a database has no effect on scheduled operations that are currently defined for report server items. Schedules will be recreated the first time you restart the Report Server Windows service. Subscriptions, cached reports, and snapshots are preserved in the moved database. Temporary report and user session data that is stored in reportservertempdb will be persisted when you move that database.

SQL Server provides several approaches for moving databases, including backup and restore, attach and detach, and copy. Not all approaches are appropriate for relocating an existing database to a new server instance. The approach that you should use to move the report server database will vary depending on whether you have up-time requirements. The easiest way to move the report server databases is to attach and detach them. However, this approach requires that you take the report server offline while you detach the database. Backup and restore is a better choice if you want to minimize service disruptions, but you must run Transact-SQL commands to perform the operations. Copying the database is not recommended (specifically, using the Copy Database Wizard); it does not preserve permission settings in the database.

Important:

The steps provided in this topic are recommended when relocating the report server database is the only change you are making to the existing installation. Migrating an entire Reporting Services installation (that is, moving the database and changing the identity of the Report Server Windows service that uses the database) requires connection reconfiguration and an encryption key reset. For more information about migrating a Reporting Services installation, see Migrating Reporting Services.

If you can take the report server offline, you can detach the databases to move them to the SQL Server instance you want to use. This approach preserves permissions in the databases. If you are using a SQL Server 2005 database, you must move it to another SQL Server 2005 Database Engine instance. After you move the databases, you must reconfigure the report server connection to the report server database. If you are running a scale-out deployment, you must reconfigure the report server database connection for each report server in the deployment.

Use the following steps to move the databases:

Stop the Report Server Windows service and Web service. To stop the Report Server Web service, you can stop the application pool that hosts the service.

Start SQL Server Management Studio and open a connection to the SQL Server instance that hosts the report server databases.

Right-click the report server database, point to Tasks, and click Detach. Repeat this step for the report server temporary database.

Copy or move the .mdf and .ldf files to the Data folder of the SQL Server instance you want to use. Because you are moving two databases, make sure that you move or copy all four files.

In Management Studio, open a connection to the new SQL Server instance that will host the report server databases.

Right-click the Databases node, and then click Attach.

Click Add to select the report server database .mdf and .ldf files that you want to attach. Repeat this step for the report server temporary database.

After the databases are attached, verify that the RSExecRole is a database role in the report server database and temporary database. RSExecRole must have select, create, update, delete, and reference permissions on the report server database tables, and execute permissions on the stored procedures.

Start the Reporting Services Configuration tool and open a connection to the report server.

On the Database Setup page, select the new SQL Server instance, and then click Connect.

Select the report server database that you just moved, and then click Apply.

If you cannot take the report server offline, you can use backup and restore to relocate the report server databases. You must use Transact-SQL statements to do the backup and restore. SQL Server Management Studio does not support copy-only backups. After you restore the databases, you must configure the report server to use the database on the new server instance. For more information, see the instructions at the end of this topic.

Using BACKUP and COPY_ALL to Backup the Report Server Databases

When backing up the databases, set the COPY_ALL argument. Be sure to backup both of the databases and log files.

-- To permit log backups, before the full database backup, alter the database
-- to use the full recovery model.
USE master;
GO
ALTER DATABASE ReportServer
SET RECOVERY FULL
-- If the ReportServerData device does not exist yet, create it.
USE master
GO
EXEC sp_addumpdevice 'disk', 'ReportServerData',
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\ReportServerData.bak'
-- Create a logical backup device, ReportServerLog.
USE master
GO
EXEC sp_addumpdevice 'disk', 'ReportServerLog',
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\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, before the full database backup, alter the database
-- to use the full recovery model.
USE master;
GO
ALTER DATABASE ReportServerTempdb
SET RECOVERY FULL
-- If the ReportServerTempDBData device does not exist yet, create it.
USE master
GO
EXEC sp_addumpdevice 'disk', 'ReportServerTempDBData',
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\ReportServerTempDBData.bak'
-- Create a logical backup device, ReportServerTempDBLog.
USE master
GO
EXEC sp_addumpdevice 'disk', 'ReportServerTempDBLog',
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\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

Using RESTORE and MOVE to Relocate the Report Server Databases

When restoring the databases, be sure to include the MOVE argument so that you can specify a path. Use the NORECOVERY argument to perform the initial restore; this keeps the database in a RESTORING state, giving you time to review log backups to determine which one to restore. The final step repeats the RESTORE operation with the RECOVERY argument.

The MOVE argument uses the logical name of the data file. To find the logical name, execute the following statement: RESTORE FILELISTONLY FROM DISK='C:\ReportServerData.bak';

The following examples include the FILE argument so that you can specify the file position of the log file to restore. To find the file position, execute the following statement: RESTORE HEADERONLY FROM DISK='C:\ReportServerData.bak';

When restoring the database and log files, you should run each RESTORE operation separately.

How to Configure the Report Server Database Connection

Start the Reporting Services Configuration tool and open a connection to the report server.

On the Database Setup page, select the SQL Server that now hosts the report server database and click Connect.

In Database Name, select the report server database that you want to use, and then click Apply.

Note:

A Reporting Services installation requires that the SQL Server Database Engine instance include the RSExecRole. Role creation, login registration, and role assignments occur when you set the report server database connection through the Reporting Services Configuration tool. If you use alternate approaches (specifically, if you use the rsconfig.exe command line utility) to configure the connection, the report server will not be in a working state. You might need to run other scripts to make the report server available. For more information, see Scripting Deployment and Administrative Tasks.