SharePoint Mirroring

There are number of posts and documents about how to setup mirroring of SharePoint content DB, but when I started my mirroring I stumbled over number issues, which I probably missed in documentation and which took some of my time to find out what was wrong. So in this post I’d like summarize all important parts of setting SharePoint mirroring.

Refer to detailed description in the end of this post to get the initial understanding.

  1. Prepare all you SharePoint Content databases for recovery. Use “ALTER Database <databasename> SET RECOVERY FULL;“ SQL command against all databases which will participate in backup and mirroring.
  2. (Optionally) Prepare content databases to be detached from web application, because in future you could rename it. To do this run “stsadm -o preparetomove -contentdb SQLSERVER:DBNAME –site <url>”.
  3. Make the SharePoint farm backup, and restore it on your Disaster Recovery (DR) box. Use OOTB backup/restore – Central Admin –> Operations –> Backup. The reason to restore SharePoint on DR box instead of straight mirroring is to have everything set and configured absolutely the same as on production box, to have minimum restoration time.
  4. After you restore your instance on DR box close SharePoint Central Admin. You don’t need it anymore :,,)
  5. Make SQL backup of your SharePoint DBs and their LOGs from production box, which will be mirrored. Usually only content databases are mirrored – search and other stuff can be missed, because it’s not so vital as content DB. I had number issues with making SQL backups and restore DBs on DR box, after you restored your new instance, so, I found more convenient to provide new copy of all DBs specially for mirroring. Make this backup with SQL commands “BACKUP DATABASE/LOG” and copy those files to DR box.
  6. Go to SQL Management Studio and delete all SharePoint DB which you want to mirror.
  7. Restore your databases with “NORECOVERY” attribute. UI doesn’t help you, so we are using SQL command “RESTORE DATABASE … NORECOVERY …” for this.
  8. After restoration completed you will see your DB with new icon and having “(recovering…)” status. Now time to apply the logs with the same “NORECOVERY” attribute and the similar command “RESTORE LOG … NORECOVERY…
  9. Wait a couple of minutes, allowing SQL server to restore some stuff.
  10. Now connect to Production SQL instance from DR box, select the database you just restored in DR, and right-mouse clicking, selecting tools->mirroring. Mirroring Wizards will start. Go through all steps. Ignore mirroring endpoints name difference. But pay attention on “encryption” settings on principal and on mirror boxes – they must be the same. Use next command to change these settings “ALTER ENDPOINT Mirroring FOR DATA_MIRRORING (ROLE = PARTNER, ENCRYPTION = SUPPORTED)” to be the same among principal and mirror boxes.
  11. Activate mirroring in the end of Mirroring Wizard, and you DB status will changed to “principal”/”mirroring”.
  12. You might have security error, saying that your DR box can’t connect to partner (production box). Go to SQL again and run the following “alter database myDatabase set partner = ”TCP://”;
  13. Repeat everything from step 6 to 11 for all SharePoint databases.
  14. To switch to DR box and start using mirrored databases, you need to go to mirroring window again and press “FAILOVER” button. This will switch your databases and DR boxes will be active. Without failover you site on DR box won’t be accessible.



1) User SQL Management Studio, right mouse click on DB, Tasks->Launch Database Mirroring Monitor to check the status of your mirroring databases.

2) You can have the following error “Cannot open database "<…>" requested by the login. The login failed. Login failed for user ”….”.” when you try to use “stsadm –o addcontentdb …”. This happens when you DB not in failover status. You need to make your DR failovered (active) and only then add content DB


That’s all. I hope this post will save some of your time when you start your SharePoint mirroring.


More reading:


Mirror: SharePoint Mirroring


  1. steve Said,

    January 30, 2009@ 4:36 pm      Reply


    I have the problem you mention in your troubleshooting, but I am not doing any mirroring. I have restored a backup of our ContentDB to a test environment and then tried to add the contentdb to my test sharepoint site using ”stsadm –o addcontentdb….” but get the error you mention (Cannot open database “” requested by the login. The login failed. Login failed for user ”….”.) in the update log.

    Why would this happen? I have done this process several time and it has always worked – any help would be greatly appreciated

  2. laflour Said,

    January 30, 2009@ 9:44 pm      Reply

    Are you sure that your called “stsadm -o preparetomove”? before detaching? missing this call gives 90% of all problems

    Try to follow this guideline how to detach and re-attach db.

  3. Boris Gomiunik Said,

    April 7, 2009@ 7:21 am      Reply

    Very nice article! Thanks for the in-depth info. Is there a way to also mirror custom DLLs in GAC and custom themes?

  4. laflour Said,

    April 7, 2009@ 8:34 am      Reply

    custom DLLs can be easily tracked by their location in the bin folder of IIS – just move them to new server and that”s all.

    GAC dlls are bit tricky to find. Actually, what you can do is to inspect the web.config section for all safecontrols dlls.
    Just create a new site (and activate published features) to have the clear web.config. And then compare section of the clear web.config with corresponded web.config you are migrating

RSS feed for comments on this post · TrackBack URI

Leave a Comment