Roland Serman’s Blog

Just another 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 Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: