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.
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, as shown in Figure 1:
backup-spfarm –BackupMethod Full –Directory C:\Backup\ -ConfigurationOnly
Backing Up an Entire Web Application
To back up a single web application using the SharePoint 2010 Management Shell, execute the following command, as shown in Figure 2:
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 BackUpThreads
parameter in backup-spfarm. The recommended value for SharePoint
Foundation is 3 threads.
Restoring a Site Collection
To restore a single site collection using the SharePoint 2010 Management Shell, execute the following command, as shown in Figure 3:
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.
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
The syntax for the Import-SPWeb command is shown in Figure 4.
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, as shown in Figure 6:
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.