Sdílet prostřednictvím


Preparing a Mirror Database for Mirroring

Before a mirroring session can start, the database owner or system administrator must make sure that the mirror database has been created and is ready for mirroring.

Creating a Mirror Database

Creating a new mirror database minimally requires taking a full backup of the principal database and a subsequent log backup and restoring them both onto the mirror server instance, using WITH NORECOVERY. The mirror database must be in the RESTORING state for mirroring to work.

Also, before you can start mirroring, if any additional log backups are taken after the required log backup, you must manually apply every additional log backup, always by using WITH NORECOVERY. If a log backup job is scheduled to run very frequently on the database, you might have to disable the backup job until mirroring has started. After you apply the latest log backup, you can start mirroring and reenable the log backup job, if it is disabled.

Note

Only the current principal server can be backed up. The mirror database cannot be backed up because it is in the RESTORING state.

Preparing a Mirror Database to Restart Mirroring

If mirroring has been removed and the mirror database is still in the RECOVERING state, you can restart mirroring. However, first, at least one log backup must be taken on the principal database. Then, on the mirror database, you must restore WITH NORECOVERY all log backups taken on the principal database since mirroring was removed.