Sunday, January 5, 2014

Backing up a SharePoint 2010 farm

There are a lot of good scripts out there to use for backing up your SharePoint.  This one is one of my favorites: 

Just download it, unzip it, create a folder to store your backups, share that folder complete the Params.xml and you're about ready to go! 

Read this detailed instruction guide written by the scripts author for step-by-step instructions:

Here is another, and probably the best script for backing up your SharePoint Farm.  It is written by John Ferringer, a SharePoint Guru -

If the Ferringer solution or the codeplex solution above seems a bit to daunting, you can copy and paste the powerhsell from this blog: into a .ps1 file and then set it up to run as a scheduled task using credentials that have Shell admin access and full control over the shared network location where the backups will be stored. 

You'll need to share a folder for the script to write into.  Here is the powershell script from bradcote with a few additional notes

# Backup all site collections in the farm, placing them in
# a directory on a shared location
# Note - Does not backup the /train site collection

# adds the SharePoint cmdlets to your powershell and effectively turns it into the SharePoint
#Management Shell

Add-PsSnapin Microsoft.SharePoint.PowerShell

# Take care of the disposable objects to prevent memory leak.
Start-SPAssignment -Global

# This is the backup path - must be shared with account that is executing the script and the
# farm account

# Remove all that backup folders created > 7 days ago
get-childitem $backupLocation |
     where {$_.Lastwritetime -lt (date).adddays(-7)} |
     remove-item -recurse -Confirm:$false

# Get current date for use in log file and format it to avoid
# invalid characters such as "/" and ":"

$today=Get-Date -format "MM-dd-yyyy"

# Create a folder in the backup location with todays date (sortable)

$todayFolder = $backupLocation + '\' + $((get-date).toString('MM-dd-yyyy'))
md $todayFolder

# Does not backup the /train site collection
# or the temporary web ap site collection on port 15702

# Disregard this, or use it, depending on whether you have a /train site collection, etc.

foreach ($site in get-spsite -limit all |
         where-object -FilterScript {$_.url -notlike "*/train*"} |
         where-object -FilterScript {$_.url -notlike "*15702"}) {
    write-Host Start backing up $site to $todayFolder
    try {
         # Create a new backup file and name it based on current date.
         # If you want to create only 1 backup file and overwrite it
         # each time the backup is run, you can replace "$today.bak"
         # with your desired file name.

         $pathName = ($todayFolder + '\' + $($site.ID) + '.bak')
         write-Host 'Backing up ' $site ' GUID = ' $($site.ID)

         # This farm does not have Enterprise SQL Server, so snapshots
         # cannot be used. This requires that the sites belocked for
         # update during the backup, so this should be run after hours

         Backup-SPSite -Identity $site -Path $pathName -EV Err
            -EA "SilentlyContinue"
         write-Host Backup succeeded.

         # Write success message to the log file
         write "$today $site GUID =
           $($site.ID) successfully backed up.">>logFile
    } catch {
        write-Host Backup failed. See $logFile for more information.
        # Write error message to the log file
        # change the logFile to some other name if you want, e.g. BackupHistory.txt
        $e = $Err[0].ToString()
        write "$today $site Error: $e">>logFile
Stop-SPAssignment -Global
Remove-PsSnapin Microsoft.sharepoint.powershell
write-Host "Finished script."

This blog has another script that you can use, also an easier to use version:

Make sure to update these variables:

$logfile = "SPFarm-Backup-" + $(Get-Date -Format dd-MM-yy) + ".log"
$ConfigDB = "SP_Config"
$DBServer = "server"
$BackupConfigFolder = "\\server\SharePoint\Backup\Config"
$BackupSAFolder = "\\server\SharePoint\Backup\ServiceApp"
$AdminEmail = <a href=""></a>
$MailServer = ""
$FromAddress = <a href="">sharepoint.notifications


Microsoft TechNet - - Backing up a Farm in SharePoint 2013

Petri blog - backup and restore advice - Good Read

John Ferringer on backups -

Microsoft's scripting guy defers to John Ferringer - - same here


No comments:

Post a Comment

Thanks for commenting, if you have a question and want a reply, please post it on TechNet forums and reference this blog, or navigate to and post it there, all of these blog posts and more are on my SharePoint Papa site.

Popular Posts