Granular Backup and Restore in SharePoint 2010 (Part 2)
By: Arshad Ali | Comments | Related: > SharePoint Administration
In my last tip, Backup and Restore in SharePoint 2010, I talked about options to backup a SharePoint farm, web applications and different components and then restore them back whenever required. But what if I have a web application with multiple site collections in it and one of the them is only getting changed frequently hence I want to backup only a specific site collection instead of backing up the complete farm or web application on regular basis? What if I want to create a copy of the site collection to another SharePoint server? What new options are available in SharePoint 2010 for site collection backup and restore?
SharePoint 2010 not only allows you to backup and restore the farm/web application/services but also supports granular backup. For example you can take a backup of any specific site collection from Central Administration. You can export site content to the file system and import it into another site. And yes, now you don't need to setup another temporary farm to just restore a small part of your site content from the backup. You can simply restore a content database on any SQL Server instance and then use the unattached content database recovery feature from Central Administration to restore the selected contents.
This tip will discuss how to backup a SharePoint site collection from Central Administration as well as from PowerShell and the STSADM command as well as restoring it back using PowerShell or the STSADM command.
Backing-up a Site Collection from Central Administration
START -> All Programs -> Microsoft SharePoint 2010 Products -> SharePoint 2010 Central Administration.
On the left side click on the Backup and Restore link as shown below, then in the detail pane click on Perform a site collection backup under Granular Backup as shown below. Please note Central Administration only allows you to take a backup of a site collection, you need to use PowerShell or the STSADM tool to restore it back when required (discussed next):
On the Site Collection Backup screen, specify the name of the site collection you want to take a backup of, the location to store the backup, the name of the backup file and the option to whether overwrite a file if it exists with the same name on the specified location. You can change the site collection selection by clicking on the Change Site Collection button:
On the Granular Backup Job Status screen, you can see the status of the site collection backup operation. This page gets refreshed automatically in every 30 seconds though you can refresh it on-demand by clicking on the Refresh link as shown below (You need to make sure the SharePoint 2010 Timer windows service is running before making a site collection backup using Central Administration):
Backing-up and Restoring Site Collection using PowerShell cmdlets
Central Administration is not the only way to do site collection backup in SharePoint 2010. SharePoint 2010 provides several PowerShell cmdlets to perform these operations. In other words you can script these operations and schedule it with Windows Task Scheduler to make it run on scheduled basis. Let's explore these cmdlets in detail.
The Backup-SPSite command is used to backup a site collection whereas the Restore-SPSite command is used to restore a site collection. The general syntax of these commands are:
Backup-SPSite -Identity <url of the site collection to be backed up> -Path <location and name of the file to be created after backup> [-Force] [-Verbose]
Restore-SPSite -Identity <url of the site collection getting restored> -Path <location and name of the backed up file to restore from> [-Force] [-Verbose]
To launch SharePoint 2010 the PowerShell console, go to:
START -> All Programs -> Microsoft SharePoint 2010 Products -> SharePoint 2010 Management Shell and click on it.
To take the site collection backup we need to use the Backup-SPSite command and specify the location where the backup will be stored, and the URL of the site collection. The Force parameter is used to overwrite a file with same name (if it exists) during the backup and overwrite a site collection with same name (if it exists) during a restore operation:
Backup-SPSite -Identity http://mktaraliw2k8r2:8081 -Path \\MKTARALIW2K8R2\SharePointBackupFolder\PrimarySiteCollection.bak -Force
Restore-SPSite -Identity http://mktaraliw2k8r2:8081 -Path \\MKTARALIW2K8R2\SharePointBackupFolder\PrimarySiteCollection.bak -Force
Backing-up and Restoring Site Collection using STSADM (SharePoint Administrative) tool
STSADM is a SharePoint administrative tool which generally resides in...
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
...on a SharePoint 2007 server and in...
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN"
...on a SharePoint 2010 environment.
This command is run on the server, by the people who are member of Administrators group. In this section we are going to see how this tool can be used to backup a site collection and restore it back when required. These are general command formats for abackup and restore of site collection.
stsadm -o Backup -URL <url of the site collection to be backed up> -Filename <location and name of the file which gets created to store backed up data> -Overwrite
stsadm -o Restore -URL <url of the site collection to restore to> -Filename <location and name of the backed up file to restore from> -Overwrite
The Overwrite switch is required to overwrite a file if it already exists on the specified location during a backup operation and, similarly, overwrite a site collection if it already exists with same name on the specified URL during restore operation. To learn about the parameters of this command, follow this link.
stsadm -o Backup -URL http://mktaraliw2k8r2:8081 -Filename \\MKTARALIW2K8R2\SharePointBackupFolder\PrimarySiteCollection.dat -Overwrite
stsadm -o Restore -URL http://mktaraliw2k8r2:8081 -Filename \\MKTARALIW2K8R2\SharePointBackupFolder\PrimarySiteCollection.dat -Overwrite
- Please note: Though you can still use old the STSADM (SharePoint Administrative) tool to perform backup and restore operations it is not recommended to use this tool (unless you are forced to use it for backward compatibility) as this tool has been deprecated and provided in SharePoint 2010 only for backward compatibility. To learn more about mapping between STSADM and PowerShell cmdlets, click here.
- To improve the performance of backup/restore operations, use a local path to minimize the latency; if required you can then move a backed up file to a network location after a backup completes or before a restore you can move from a network location to a local path and then start restore operation.
- If your SQL Server version supports a database snapshot (Enterprise and Developer editions) , it is recommended to use the UseSqlSnapshot parameter with the Backup-SPSite command for a more consistent backup.
- Additional related PowerShell cmdlets are, Get-SPSite, Move-SPSite, New-SPSite, Remove-SPSite, Set-SPSite, Get-SPSiteAdministration etc.
- You need to make sure the SharePoint 2010 Timer windows service is running before taking a site collection backup using Central Administration.
- The recommended maximum size for a site collection backup is 15GB in SharePoint 2007 and 85GB in SharePoint 2010.
- Review Creating Web Applications, Site Collections and Sites in SharePoint 2010 tip.
- Review Backup and recovery overview on technet.
- Review Part 1 of this series on Backup and Restore in SharePoint 2010
About the author
View all my tips