Friday, March 9, 2012

Moving ReportServer databases example in error?

The following link shows an example of backing-up and restoring the databases supporting Repor Server. My question is not so much Report Server-related but I question the restore syntax for restoring the logs.

http://msdn2.microsoft.com/en-us/library/ms156421.aspx

I honestly do not see how the following code would work. At least, I was not able to until I deleted everything after the "NORECOVERY". Then it seemed to work fine but maybe I missed something!

-- Restore the report server log file to new instance folder
RESTORE LOG ReportServer
FROM DISK='C:\ReportServerData.bak'
WITH NORECOVERY, FILE=2
MOVE 'ReportServer' TO
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ReportServer.mdf',
MOVE 'ReportServer_log' TO
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ReportServer_Log.ldf';
GO

Thanks a lot!

Your database is not ready if you stop after "with norecovery" restore. This basically puts the database in "recovering..." state (i.e. waiting to recover or roll forward/back transaction). You will have to run the following to recover the database.

-- Perform final restore
RESTORE DATABASE ReportServer
WITH RECOVERY
GO

-- Perform final restore
RESTORE DATABASE ReportServerTempDB
WITH RECOVERY
GO

|||

Everything you said is true and is actually included in the code sample on the link. I did not include it because it is not directly related to my question.

thanks

|||

you mean if you remove this portion of code

<code>

FILE=2
MOVE 'ReportServer' TO
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ReportServer.mdf',
MOVE 'ReportServer_log' TO
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ReportServer_Log.ldf';

</code>

then it works? Well, there is a missing comma after "FILE=2" and before "MOVE". The correct syntax would be

<code>

FILE=2,
MOVE 'ReportServer' TO
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ReportServer.mdf',
MOVE 'ReportServer_log' TO
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ReportServer_Log.ldf';

</code>

No comments:

Post a Comment