Mostefai Mohammed Amine

Software and Cloud Architect

Amine
  • Contact
Previous Post
Next Post
Jan 19, 2015 PowershellSharepointSharepoint 2013

Using Powershell to backup all the Sharepoint site collections

 

One of the most pleasing things about Sharepoint is the ability to do the same administrative action in a multitude of ways: through the central administration UI, Powershell, or using the object model. Powershell is not only the indisputably most preferred administrative way, but for some actions, it is the only way.

In this example, I will show a script that uses the power of Powershell pipelines to backup all the site collections.

The method is simple, using the Get-SPSite command; I get all the site collections. After I iterate in the collection using For-EachObject. For each collection, I build a backup path by using the site URL and by replacing the symbols by “_”. After, I backup each site using the command Backup-SPSite. Notice that I use the $_ alias which is very useful to manipulate objects in iterations.

This is the simple script that expresses all the power of Powershell

get-spsite -Limit All | ForEach-Object {$path = $_.Url.Replace("/","_").Replace(":","_"); $path="c:\backup_path\$($path).bak"; Write-Host "Backing the collection $($_) up using the path $($path)...."; Backup-SPSite $_ -Path $path; Write-Host "The backup of the collection $($_) has been performed successfully"}

Enjoy Sourire

Get-SPSiteBackup-SPSiteSharepointsharepoint 2013powershell
Share This Post

Related posts

  • Using Powershell to backup all the Sharepoint site collections   One of the most pleasing things about Sharepoint is the ability to do the same administrative
  • Resolving the “Accessing referenced file from is not allowed” issue in Sharepoint Very often, Sharepoint publishing pages display the following message after modifying the master pag
  • Create an intranet site with Sharepoint Hi Everyone Back now after moving to Malaga :)  
Saving the comment

Cancel reply to comment

The captcha value you provided is incorrect.