Roland Serman’s Blog

Just another WordPress.com weblog

Using PowerShell to backup SharePoint 2010 Site Collections

Here is a handy script I use for backing up all of my SharePoint site collections. Many thanks to Todd Klindt for providing the bulk of it in a one liner.  I had to make a few tweaks, most notably the “-limit all” and the .Replace for https://.&#160; Make sure to replace anything in <> with your own values.

Add-PsSnapin Microsoft.SharePoint.PowerShell

Get-SPWebApplication | Get-SPSite -limit all  | foreach {
    $FilePath = \\">\\">\\<ServerName>\<ShareName>\;
    $ext = $_.Url.Replace("http://", "").Replace("https://", "").Replace("/","-").Replace(":","-") +".bak";
    write-host $ext
    Backup-SPSite -Identity $_.Url -Path $FilePath$ext -Force
}

Check out Todd’s blog, he has a lot of good info, including similar script to backup webs.

Leave a comment