Tuesday, August 7, 2012

How To Restore a Deleted Site Collection in SharePoint 2010

The recent release of Service Pack 1 for SharePoint 2010 included the Site Recycle Bin for restoring deleted sites. However, what if you deleted a whole Site Collection? Well, Service Pack 1 comes packaged with 3 new PowerShell commands to handle just that:
  • Get-SPDeletedSite
  • Restore-SPDeletedSite
  • Remove-SPDeletedSite
A Site Collection at https://portal.contoso.com/sites/HR was recently deleted by accident. Let’s use our best friend, PowerShell, to get that site back and keep the news (and headache) from our SQL DBAs.
Open up the SharePoint 2010 Management Shell with an account that has the proper SPShellAdmin rights. Next, use Get-SPDeletedSite to locate the deleted Site Collection:

Get-SPDeletedSite -Identity /sites/HR


Notice how we have to use a server relative URL for the Identity parameter and not the full URL like we typically use when using this parameter with Get-SPSite.




This is also assuming we know or remember the server relative URL that was deleted. In case you are forgetful, like me, we can replace the Identity parameter with ContentDatabase, WebApplication, or even conduct a date range with DateTimeFrom and DateTimeTo:


Now, to restore the Site Collection run the Restore-SPDeletedSIte command with the same server relative URL Identity parameter:

Restore-SPDeletedSite -Identity /sites/HR



However, we can simplify this a little further when performing this next time by piping the result from Get-SPDeletedSite directly to Restore-SPDeletedSite like so:

Get-SPDeletedSite -Identity /sites/HR | Restore-SPDeletedSite




The ability to put the restore of both Sites Collections and Sites into the users and admins hands will surely make DBAs, Farm Admins, Help Desk, and a lot of others sleep much easier at night!

3 comments:

  1. hi,is it possible in wss 3.0.Actually i created a site and updated some important data in it.accidentally it is deleted by some one.I need that data.Please let me know the way to get it

    ReplyDelete