Saturday, January 12, 2013

Using SharePoint 2010 Management PowerShell for Backup and Restore


SharePoint 2010 Management Shell built on Windows PowerShell is installed with SharePoint Foundation and SharePoint Server 2010. Although the STSADM command is available with SharePoint 2010, it has been deprecated to provide backward compatibility with previous versions. SharePoint 2010 administrators have now been armed with a powerful management shell to administer SharePoint 2010 environments. SharePoint 2010 Management Shell is far more powerful than SharePoint Central Administration and STSADM combined. SharePoint Central Administration is limited in functionality to what is represented in GUI, whereas SharePoint 2010 Management Shell is highly extensible with more than 600 prebuilt cmdlets available at the time of writing, in addition to support for creating custom cmdlet.
1. Backing Up the Farm Configuration Using PowerShell
To back up farm configuration using the SharePoint 2010 Management Shell, execute the following command from within the PowerShell Shell.
backup-spfarm –BackupMethod Full –Directory C:\Backup\ -ConfigurationOnly
2. Backing Up an Entire Web Application
To back up a single web application using the SharePoint 2010 Management Shell, execute the following command,
backup-spfarm –BackupMethod Full –Directory C:\Backup\ -Item http://server
Note: http://server is the name of the web application to be backed up using the Full method. If the web application is being backed up for the first time, it has to be full backup, or else the backup will fail in case of first-time differential backup.
The advantage of using Windows PowerShell is in executing multiple instances of Windows PowerShell scripts to back up site collections using the Backup Threads parameter in backup-spfarm. The recommended value for SharePoint Foundation is 3 threads.
3. Restoring a Site Collection
To restore a single site collection using the SharePoint 2010 Management Shell, execute the following command.
Restore-SPSite –identity http://server/sites/it -path c:\backup\it\itbackup.bak –force
Note: We have used force to overwrite the site collection in the web application.
4. Import Site or List
To import a list within a site using the SharePoint 2010 Management Shell, execute the following command from within the PowerShell Shell:
Import-SPWeb –Identity http://servers/sites/IT/Announcements/ -Path C:\Backup\IT\Announcements.cmp –IncludeUserSecurity
5. Importing a Site
Before you can import your web, you need to create the site. To create a site using the SharePoint 2010 Management Shell, perform the following steps:
Execute the following command from within the PowerShell Shell:
New-SPWeb –URL http://server/sites/IT/Blog/ -Verbose
Verbose parameter has been used to see how this cmdlet executes and creates a new site, as shown in Figure 5. After the site has been created, it can be overwritten with the backup using the following steps:
To import a site using the SharePoint 2010 Management Shell, execute the following command.
Import-SPWeb –Identity http://server/sites/IT/Blog/ -Path C:\Backup\IT\Blog.cmp –IncludeUserSecurity –UpdateVersions Overwrite

With SharePoint 2010, backup and restore of site collections, sites, or lists can now be easily done with the Central Administration tool or SharePoint 2010 Management Shell. This functionality has been removed from SharePoint Designer 2010.

 

 

No comments:

Post a Comment