Friday, August 7, 2009

Oh NO! I deleted a site that I shouldn't have!

There is no recycle bin for sites. You probably know this, or you or your users found this out the hard way. This has happened to me more than once, and is the topic of a previous post about removing the 'delete this site' link.

Let's stay that you haven't done that, and you don't have a nice SharePoint backup solution that will let you easily restore deleted content. A user has just deleted a site and has come to you to get it back.

Possible solutions:
Solution 1:
Copy your backups(you have those right? :P ) to another SharePoint server and create a new Web Application using that DB. That site should now have the content that you lost. Migrate it back over to your production portal.
This is a solution, but migration can be a pain the butt. Also, it assumes you've got backups. You'll lose all your version history, and information about created and last modified. If your site is small enough you might be able to make a template out of it and rebuild a new site from there. You might even be able to use stsadm to backup and restore. Both of those options will run into trouble if your site is too big or complex.

Solution 2:
Roll back the database to a time before this disaster happened. This solution will work if you don't have backups(I think) :) and everything will seem as if nothing happened. The down side is that you will have lost everything that has happened before the roll-back point. Hopefully you were alerted quickly to the problem.
First, make a backup of your transaction logs. if you already have backups, this should be enough. If you don't, you'll want to backup the site as well.
Next, Restore a Database. Give it a new name, and pick a time that you know to be before the problem happened(but not too far back or else you'll lose more data). Choose your live database as the place to restore from. You should see it list your backup's. If you didn't back up your transaction log, you'll only be able to restore to the last backup. That is why it is important to backup your transaction log before you start.
Once the restore is complete, you'll have a copy of the DB from before the problem happened. detach your production DB, and rename this restored copy to the production name. You should be good to go.
You may want to shut down the site when you do this so that no new data is uploaded, since it will be lost. If done correctly, you should be able to restore the site very quickly, but it depends on how big your content DB is and how much traffic you get.

Good luck! And now go delete the "delete this site" link from your _layouts/settings.aspx page so that users can't do this again in the future :P