Friday, October 15, 2010

SharePoint Content DB Restores

I know there are already a ton of articles, posts, etc. out there about this, but I have yet to find one that addresses all of these situations at once. In helping to administrate a SharePoint farm with 1000+ sites in well over 50+ site collections, I have had the opportunity to mop up after a few bone-headed blunders. Things had been quiet for some time and then I got a request to restore an excel file from 6 months ago. Turns out the library it was in did not have versioning turned on.

I was fairly sure on what I needed to do, but a little fuzzy on the exact procedures. "No problem", I said to myself, "I'll just pull up the documentation from the last time I did this." Oops! Apparently I did not document it last time, or I forgot where I put it, 'cause I couldn't find it anywhere. So this time around I made documentation and figured I would share it with the rest of the world. I'm sure there are other ways to do this, but I went for easy to follow, rather than sophisticated. Enjoy!

Restoring SharePoint Site or Item from Content Database Backup

Precautions

  • If an entire site collection is not to be restored, then the content database must be restored to a staging farm.
  • The staging farm must be the same version/build as the production farm.
  • Any features (.wsp) that are active for the site in question on the production farm must be installed on the staging farm.

Procedure

Restoring a site collection

To restore from a current version/build content db

  1. Stop the IIS website of the site collection to restore.
  2. Using SQL Server, set the content database for the site collection into single user mode.
  3. Restore the content db according to SQL Server db restore practices.
  4. Restart the IIS website.

To restore from a previous version/build content db

  1. Stop the IIS website of the site collection to restore.
  2. Using SharePoint Central Administration remove the content db of the site collection to be restored.
  3. Using SQL Server, set the content database for the site collection into single user mode.
  4. Restore the content db according to SQL Server db restore practices.
  5. Use the stsadm –o addcontentdb command to add the content database to the site collection (stsadm –o addcontentdb –url  -databasename ). Other options may be needed.
  6. Restart the IIS website.

** Please note that it is not required to start and stop the IIS site, but in some cases it is more user-friendly.

Restoring a web (sub web)
  1. Create an empty site collection on the staging farm (this can be a root or a sub site collection)
    • Sub site collections are a little more tricky and may be best created via the stsadm –o createsiteinnewdb command.
  2. Restore the content db according to SQL Server db restore practices.
  3. Using SharePoint Central Administration or stsadm, take the current content db for the site collection offline, or remove it.
  4. Use the stsadm –o addcontentdb command to add the content database to the site collection (stsadm –o addcontentdb –url -databasename ). Other options may be needed.
  5. Use the stsadm –o export and stsadm –o import commands to export the specific sub web from the staging farm and import it into a specified location on the production farm.
    • It may be beneficial to use various options from the export and import commands to preserve security, etc.
Restoring an item
  1. Create an empty site collection on the staging farm (this can be a root or a sub site collection)
    • Sub site collections are a little more tricky and may be best created via the stsadm –o createsiteinnewdb command.
  2. Restore the content db according to SQL Server db restore practices.
  3. Using SharePoint Central Administration or stsadm, take the current content db for the site collection offline, or remove it.
  4. Use the stsadm –o addcontentdb command to add the content database to the site collection (stsadm –o addcontentdb –url -databasename ). Other options may be needed.
  5. Find the item in question and move it to the production farm by whatever action(s) seem prudent.

Off the Market!

First of all, my apologies for not posting in some time. The tail end of the summer got quite busy for me, and although I was inspired to post some stuff here and there, alas, I did not. I do have a good reason however... I got married in September (destination wedding) and had a reception back home in early October.

As any good man knows, during the time approaching these events, I was at my bride's beck and call to help make sure things went as planned, and to help shoulder some of the stress involved with planning, etc. Now that we are through everything life seems simpler and we again have free time to take-up extra curriculars again. So the posting is back on!