Monday, February 7, 2011

Restoring SQL for mirroring

If the path of the mirror database differs from the path of the principal database (for instance, their drive letters differ), creating the mirror database requires that the restore operation include a MOVE clause.

Important note Important

If the path names of the principal and mirror databases differ, you cannot add a file. This is because on receiving the log for the add file operation, the mirror server instance attempts to place the new file in the location used by the principal database.

For example, the following command restores a backup of a principal database residing in C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\ to a different location, D:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\, where the mirror database is to reside.

RESTORE DATABASE AdventureWorks2008R2    FROM DISK='C:\AdventureWorks2008R2.bak'    WITH NORECOVERY,        MOVE 'AdventureWorks2008R2_Data' TO           'D:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\AdventureWorks2008R2_Data.mdf',        MOVE 'AdventureWorks2008R2_Log' TO          'D:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\AdventureWorks2008R2_Log.ldf'; GO


The above path is for reference only, check the correct path on the mirror database and repeat the process for full backup and transactional backup.

No comments: