SharePoint 2010′s New Granular Content Restore Capability
In a previous post, I documented some of the exciting new functionality that PowerShell provides for backing up a SharePoint 2010 farm. Now, let’s look at the other side of the coin – restoring.
Restoration is usually needed in one of three basic scenarios:
- A user has deleted or messed up some critical content.
- An administrator has had a configuration mishap.
- A natural / man-made disaster or hardware failure has completely taken down the farm.
The way you would go about recovering from each of these scenarios would be very different. In this post, I’ll address the first – Content Deletion. I’ll do a follow-up post to address the admin-level mishaps and recovery from a true disaster.
For now, let’s pretend that some well-meaning power user has been trying to clean up the Logos library in our root site to eliminate redundancy and recover some space within our quota. However, they have inadvertently deleted the logo used as our site image – and in a quest to be thorough they’ve deleted it from both Recycle Bins before they noticed the problem.
We can now use the Central Admin site to look for a content database backup that predates the deletion, and then restore the content at as small of a scale as possible.
- Go to Start > Administrative Tools > SharePoint 4.0 Central Administration, and then click the Backup and Restore link on the left.
- Click on the ‘Restore from a backup‘ link in the top section of the page, select the appropriate backup from the list, and click Next.
(If you don’t see your backup listed, try changing the Backup Directory Location entry and clicking the Refresh button.)
- Drill down through the hierarchy displayed to find the content database you need, and check to box to select it. Then click Next.
- Select New configuration, and enter either a new directory name, database name, or server name. Then click the Start Restore button.
- The timer service will now schedule and immediately run a job that asks the back-end SQL server to restore the old database without overwriting the live one. The time it takes will obviously vary according to the size of the database and the concurrent activity on the SQL server. The Job Status page will likely eventually show an error related to attaching the database to the Web Application. That’s not a problem – we didn’t want the old database to be attached anyway.
(Note: You cannot restore over an existing database. You must either specify a new name / server or delete the previous database.)
- Return to the Backup and Restore page via the left-hand navigation pane, and click the Recover data from an unattached content database link in the bottom section.
- Enter the Database Server and Database Name, choose to Export site or list, and then click Next.
- Select the relevant Site Collection, Site, and List, enter a Filename (and path), and versions that you need. Then click Start Export.
- The Job Status screen will hopefully show a Succeeded message, and tell you that the cmp file is ready to be imported using PowerShell.
- Go to Start > Administrative Tools > SharePoint 4.0 Management Console, and type the following command:
Import-SPWeb –Identity http://yourportalURL –Path filenameandpathtocmpfile –Updateversions 3
This one felt a bit disconcerting to me at first, but we have to understand how the cmp file and the import command work. Notice the command is Import-SPWeb, not SPList. This is why it only asks us for the web application identity instead of the web or list identity. The cmp file we exported earlier contains the path all the way to the list and what’s available for importing (the contents of a single list in this example). Therefore, when the import command goes to read the cmp file, it is willing to import anything it contains – but only finds the items in the Logos library. The –Updateversions 3 parameter allows us to only restore items that don’t exist in the live library, ignoring the items that already exist. (For a complete explanation of the Import-SPWeb cmdlet, its parameters, and its usage, see its topic in the online SharePoint 2010 PowerShell Reference forum.)