Tuesday 27 December 2011

SharePoint 2010 - PowerShell Content Database Backup

“This post details the steps for backing up the content database of a SharePoint site through PowerShell.  Click here to view the steps for backing up a content database through Central Administration.”

PowerShell provides a means to backup data within SharePoint through the following command:

Backup-SPFarm -Directory [Path] -BackupMethod [Full|Differential] -Item [BackupItem] -Verbose -Percentage [Percentage]

Further information on each of the parameters in this command are outlined bellow.

Directory

The Directory parameters specifies the path where the backup will be generated.  This can either be a UNC path or a location on the server.   “You don’t need to enter the spbr* folder name as this will be auto generated”

BackupMethod

The backup method parameter details the type of backup that will be performed.  This can either be Full or Differential:

  • Full - backs up the selected content with all history
  • Differential - backs up all changes to the selected content since the last full backup
  • Item

    The item parameter specifies the component within the farm that will be backed up.  If the item has a unique name you can use just that, however, if it doesn’t then you will need to us the path to the item within the farm.

    In order to get the path to the item you can use the following command:

    Backup-SPFarm -ShowTree

    This will list the tree structure of items within the farm.  In my experience the path to a content database within the farm is in the following format:

    “Farm\Microsoft SharePoint Foundation Web Application\[Site Name]\[Content Database Name]”

    Verbos

    This parameter is optional.  The verbose parameter provides more information about the operation being run.

    Percentage

    This parameter is optional.  The percentage parameter can be used to report progress about the operation at defined percentage intervals.

    1 comment: