Pages

Showing posts with label Site Collection Restore. Show all posts
Showing posts with label Site Collection Restore. Show all posts

Friday, February 8, 2013

Powershell Script for back and Resote Site Collections

Recently I had to backup a whole bunch of Sites in SharePoint and move it to a new site collection. There is powershell command to backup and restore the site or site collection which is what i used but there were 100 sites that needs to be moved. I decided to quickly put together a script that can loop and copy all the available site in SharePoint.

Similarly I created the Restore script that copies the site backup to the new site collection. I am sharing this here hoping someone will benefit and not have to invent the wheel over and over again.



Back up Script

$mysitesurl = "http://vsspsandbox/my/*"
$backuppath = "c:\backup\mysitebackup."
$webapp = "http://vsspsandbox/"
Get-SPSite -WebApplication $webapp -Limit ALL | where { $_.Url -like $mysitesurl } | ForEach-Object{ $path = $backuppath + $_.Url.Substring($_.Url.LastIndexOf("/")+1); Backup-SPSite -Identity $_.Url -Path $path -Verbose }


Thursday, February 16, 2012

Restore Deleted Site Collection using power shell

Usually  I do not had a backup of my  my development machine as am not too much worried about information in the site collection. I do not mind creating a new site collection in my dev environmnet, but this time I have built this document management application and had some configuration done which I am due  to present in the conference and accidentally deleted my site collection. Now is a big problem because i only have an hour for the conference where we are showing this product to potential customers. I felt really bad for not having a backup. I was scrambling for help and started to build new site collection and deploying my solution, my friend walked into my office to get ready for the presentation. He saw me configuring the system again and asked me about the situation. I explained him what happened. He is a developer working on the same product and he brought to my notice about our previous presentation for our technical team about PowerShell commands in Sharepoint. we had to update our power shell  presentation then with few new commands that was part of SP1 release.Here is a savior and command is nothing but to restore deleted site collection. 

When you delete the site collection there is now a Site Collection Recycle Bin in Sharepoint 2010 from where you restore it using this command. I have included the Screen shot and the command below. I wanted to pen it down here because I will now remember and would be helpful for some one somewhere in the world.

Commands




Get-SPDeletedSite
Get Deleted Site


Get-SPDeletedSite | where{$_.SiteId -eq “Guid of Site ID″} | Restore-SPDeletedSite


Restore Deleted Site collection


You can find the reference to these Commands Here