Taking Backup of All Sharepoint Site Collections Simultaneously

Some days before I face a issue to format my PC. I felt to tedious to take backup of all my webapplications and site collections from my SharePoint Server, as I have many web application and so many site collections on those web application.

I also don't want to lose any single site collection, as they can be required or useful any time.

For Solving this Issue I do some R&D and create a PowerShell Script which Automatically iterate from all web applications and site collections and take their backups, I am sharing it for all my blog visitors.


<# Script to take backup of all web application and sites from the sharepoint server. #>

$FolderPath = "E:\Backup\" // Folder path to take Backup of all Objects
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null)
{   
                Write-Host "Loading SharePoint Powershell Snapin..."   
                Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
foreach ($SPWebApplication in (Get-SPWebApplication)) {
    foreach ($Site in $SPWebApplication.Sites) {
        $Filename = $FolderPath + $SPWebApplication.Name.Replace(" ","") + " " + $Site.ServerRelativeUrl.Replace("/","_")+ ".bak"
        Write-Host "$Filename"
        backup-spsite -identity $Site.URL -path $FileName -Force
    }
}

I am also planning to add script to take backup of all the wsp's from the central admin if anyone required, so that can be redeploy in new server easily. 

Please give your comments regarding these scripts.

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...