Showing posts with label farm. Show all posts
Showing posts with label farm. Show all posts

Tuesday, April 2, 2013

Simple Powershell Script to take backup of all site collections in all webapplications in a farm


$webapps = Get-SPWebApplication
foreach($app in $webapps)
{
    $siteCollections = $app.Sites
  
    foreach($sc in $siteCollections)
    {
        $loc="c:\Backups_sitecolls\"+$sc.Url.Substring(7).Replace(':','')+".bak";
        $loc=$loc.Replace('/','_');
        "backing up " + $sc.Url
        Backup-SPSite -Identity $sc.Url -Path $loc -Confirm -Force -NoSiteLock
      
    }
}
This script clears the http:// section of url and replaces and replaces / with _ in the file name of site collection.
This needs a folder "c:\Backups_sitecolls\".
Replace : before port number with empty character.