IT tutorials
 
Applications Server
 

SharePoint 2010: Performing Backups and Restores (part 1) - Using Windows PowerShell

11/29/2012 11:39:21 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
In the following sections, you will learn how to perform backups and restores in SharePoint 2010 using Central Administration or the command-line tools; you will also learn how to back up and restore SharePoint 2010 using Windows PowerShell or STSADM. In addition, there is information about how to troubleshoot your backups and restores in the event you have problems with them. SharePoint 2010 includes the backup and restore options that were in previous versions and introduces several new options that allow you to perform SharePoint backups and restores at a more granular level.

1. Using Central Administration

The Central Administration user interface is the easiest way to perform a backup or restore operation. The backup and restore utilities are divided into two sections within the Backup and Restore interface: Farm Backup And Restore and Granular Backup. From the Farm Backup And Restore section, you can

  • Start a new backup or restore job

  • Configure backup settings

  • View the backup or restore job history

  • View the status of the backup or restore jobs currently running

New in SharePoint 2010, you can perform more granular backups at the site collection, site, list, and library level using Central Administration, from the Granular Backup section of the Backup And Restore interface. Use this interface to perform the following tasks.

  • Start a site collection backup

  • Export a site or list

  • Recover data from an unattached content database

  • Check the status of a currently running granular backup job

The Central Administration Backup And Restore utility does has some limitations that should be noted.

  • It does not allow backups or restores to be scheduled.

  • It does not allow more than one Web application or service application to be backed up at the same time without performing an entire farm backup.

  • It does not allow you to make backups directly to tape.


Note:

Restore operations can be performed only at the same level as the backup; as a result, the lowest level that you can restore with this tool is an individual list or library.


Although it is not possible to make a backup directly to an external tape device using this interface, you can move the backup files to tape or another external device as a separate step when the backup is complete. In fact, you should make a copy of the backup files using this technique whenever possible, because it adds another layer of protection by providing you with backup copies that can be stored offsite.

As with the Backup and Restore tools provided with Microsoft SharePoint Server 2007, you can back up to either a local or network drive using either Central Administration or the command-line tools. However, the location you specify for backups must be available to your WFEs and SQL servers, so often a network drive is required when the farm scales beyond a single server.

The backup process automatically creates subfolders in the specified location for each subsequent backup, with the exception of granular backups—no folder is created during a granular backup; instead, the backup file is created in the actual directory specified.


Note:

BEST PRACTICES It is a best practice to use a centrally located file share for backups that is accessible by all production and test servers and is backed up on a regular basis. This can be the same file share used for SQL Server database backups, but be careful not to overload storage spindles or network bandwidth if multiple backups are occurring simultaneously. Large organizations will do well to utilize a Storage Area Network with the Universal Naming Convention (UNC) served from a Windows server for this purpose.


You can specify the location of the file backups when using the Backup And Restore user interface. However, if you need to change this location at a later time, be sure to leave your original backup location available for the length of time required to meet your SLAs. If you need to restore from a previously created backup source, change the location when viewing the Select Backup To Restore page.

If you are performing a backup to a file share, the following accounts require Change and Read share permissions on the target file share, and all NTFS security permissions are required, with the exception of Full Control.

  • The account authenticated to Central Administration when using the UI

  • The logged-on account when manually running Stsadm.exe

  • The Run As account when scheduling scripted backups in Control Panel

  • The Central Administration pool account in Internet Information Services

  • The SQL Server account, if Local System is the SQL service account

  • The SPTimer service account, if using the Central Administration UI (which is by default the same account used by the Central Administration App Pool)

2. Using Windows PowerShell

SharePoint 2010 introduces Windows PowerShell as the recommended command-line tool for managing your SharePoint farm backups and restores.

Your SharePoint 2010 disaster recovery plan will most likely include Windows PowerShell commands for scripting and automating your backup commands. For faster restore operations, you should also script your restore commands. Every backup and restore option available in the Central Administration Backup And Restore interface is also available using SharePoint 2010 Management Shell. 

You can use Windows PowerShell for SharePoint 2010 to back up and restore SharePoint components manually or as part of a script that can be run at scheduled intervals. To use Windows PowerShell, you must be a member of the Administrators group on the computer that is running Microsoft SharePoint 2010 Central Administration.

If you do not use the –Verbose parameter with your backup commands, the Windows PowerShell command prompt window will not display any message—unless the operation fails. If the backup fails, you will receive a message similar to the one shown here.

Backup-SPFarm: The backup job failed. For more information, see the error log that
is located in the backup directory. At line: <line> char:<column>. + <cmdlet> <<<<
<location of error>

					  

To assist in troubleshooting any SharePoint backup job that fails, generates errors, or generates warnings, review the Spbackup.log located in the Backup directory that you specified in the backup command. To troubleshoot any SharePoint restore job that fails, generates errors, or generates warnings, review the Sprestore.log located in the BackupShare folder from which you are restoring the backup.

When you perform SharePoint backup operations, a plain-text log file called Spbackup.log is created in the destination of your backups, as shown in Figure 1. You can view this log file to troubleshoot your backups.

Additionally, when you perform restore operations, a plain-text log file called Sprestore.log is created in the location of the backup you are restoring, and you can view it to troubleshoot your restore operations.

Figure 1. Sample Spbackup.log file


Similar to when you make a backup using Windows PowerShell, if you don’t use the –Verbose parameter with your Windows PowerShell restore commands, the Windows PowerShell command prompt window will only display a message if the operation fails. If the restore operation fails, you will receive a message similar to the one shown here.

Restore-SPFarm: The job failed. At line: <line> char:<column>. + Restore-SPFarm <<<<
<Error Message>

					  

Table 1 contains a list of the Windows PowerShell cmdlets and the associated SharePoint components that can be controlled using the corresponding cmdlet.

Table 1. Windows PowerShell Backup and Restore cmdlets
CMDLETSHAREPOINT COMPONENT
Backup-SPFarmEntire farm

Service applications

Web applications

Content databases
Restore-SPFarmEntire farm

Farm configuration only

Service applications

Web applications

Content databases
Backup-SPConfigurationDatabaseFarm configuration only
Backup-SPSiteSite collection
Restore-SPSiteSite collection
Export-SPWebSites

Subsites

Libraries

Lists
Import-SPWebSites

Subsites

Libraries

Lists

You can use the Windows PowerShell Backup and Restore cmdlets from within the SharePoint 2010 Management Shell or from within a script to perform a backup or restore operation. You use different cmdlets to perform backups and restores, depending on what level of a backup or restore you want. For instance, for a farm level backup, use the Backup-SPFarm cmdlet, but if you want to create a site collection backup, use the Backup-SPSite cmdlet. For a list of the backup and restore cmdlets, see Table 1.

2.1. Using the Backup-SPFarm and Restore-SPFarm cmdlets

The Backup-SPFarm and Restore-SPFarm cmdlets are used to perform backups and restores on the following SharePoint 2010 components.

  • Entire farm

  • Service applications

  • Web applications

  • Content databases

There are several parameters available when using the Backup-SPFarm and Restore- SPFarm cmdlets. These parameters and their uses are listed here.

  • –Directory <UNC path> Specifies the (UNC) path of the backup folder. The UNC path should be created on a server in the same domain, with share and security permissions as previously defined. A unique directory beginning with SPBRnnnn will be created for each backup operation.

  • –ConfigurationOnly Backs up site customizations only.

  • –ShowTree Primarily used to identify single items that you want to back up, but this parameter is also useful for accessing a comprehensive view of your server farm. Be aware of the following indicators when viewing the results of the –ShowTree parameter.

    • Items between square brackets [ ] cannot be selected.

    • Items that have an asterisk * next to them are not selected to be backed up.

  • –Item Indicates the name of the farm component, content database, service application, or Web application that you want to back up or restore. Type Backup-SpFarm –ShowTree to display a list of all farm components so that you can determine the exact name of the component. You can use the full farm path name as displayed from the –ShowTree option or just the name of the component if it is unique. Be sure to place double quotation marks around any items or paths that contain spaces.

  • –Percentage Controls the granularity of on-screen feedback as the operation progresses. (If you are scheduling the script to run, this parameter will be of no value to you.) Supply a value between 1 and 100 to indicate at what percentage of the job you want the status information to appear. The default is 5, which means that an updated status display will appear as every 5 percent of the backup job completes.

  • –Force Used to force the operation to complete.


Note:

The Backup-SPFarm and Restore-SPFarm cmdlets also support all of the common parameters, such as Verbose, Debug, ErrorWarning, ErrorAction, and so on. To retrieve additional information on these common parameters, use the following command.

Get-help about_commonparameters


There are also some parameters that are specific to either the backup or restore cmdlets operations.

2.1.1. Parameters Specific to the Backup-SPFarm Cmdlet

The following parameters are specific to the Backup-SPFarm cmdlet.

  • –BackupMethod <Full | Differential> At least one full backup must first be performed before a differential backup can be performed on a new farm, database, Web application, or service application. Also, the most recent differential backup is required when restoring content.

  • –BackupThreads If you have a large implementation and require significant throughput on your backups, this option can increase the amount of processing time allocated to backups. Be careful; increasing this value on a production server can degrade the quality of service experienced by the end user. You can specify a value between 1 and 10, and the default is 1.

2.1.2. Parameters Specific to the Restore-SPFarm Cmdlet

The following parameters are specific to the Restore-SPFarm cmdlet.

  • –RestoreMethod <New | Overwrite> To restore to a different farm, such as a recovery farm, use the New parameter. To restore to the same farm, use the Overwrite parameter. If you use the Overwrite option, you will be prompted to confirm that you want to overwrite the existing data.

  • –RestoreThreads If you have a large implementation and require significant throughput on your backups, this option can increase the amount of processing time allocated to backups. Be careful; increasing this value on a production server can degrade the quality of service experienced by the end user. You can specify a value between 1 and 10, and the default is 1.

  • –BackupID This parameter is used to specify the globally unique identifier (GUID) of the backup that is to be restored. If you don’t specify a BackupID, the most recent backup is restored. If you need to retrieve the BackupID, you can do so using the following command:

    Get-SPBackupHistory -Directory <Backup folder> -ShowBackup [-Verbose]

2.2. Using the Backup-SPConfigurationDatabase cmdlet

SharePoint 2010 introduces the much-needed ability to back up and restore the farm configuration database. The configuration database backup operation creates a backup file containing the following farm configuration information extracted from the farm configuration database.

  • Antivirus settings

  • Information rights management (IRM)

  • Outbound e-mail settings (only restored when performing an overwrite)

  • Customizations deployed as solutions

  • Diagnostic logging

  • Workflow

This backup operation can be run regardless of whether or not the configuration database is currently attached to the farm. You can use this backup and restore process in the following scenarios.

  • Move configurations from a test or development environment to a production environment.

  • Move configurations from a stand-alone installation to a farm environment.

  • Configure a farm to serve as part of a standby environment.

The following are some of the most common parameters used with Backup-SPConfigurationDatabase to back up your farm configuration

  • –Directory <UNC path> Specifies the (UNC) path of the destination backup folder. The UNC path should be created on a server in the same domain, with share and security permissions as previously defined.

  • –DatabaseCredentials Specifies the password for the administrator username for the SQL Server configuration database. This is only necessary if you are performing a backup of the database from an account that does not have the SQL Server db_backupoperator fixed database role.

  • –DatabaseName Specifies the administrator username for the SQL Server configuration database in the format of domainname\username.

  • –DatabaseServer Specifies the server where the SQL Server configuration database resides.

The following is an example of using Backup-SPConfigurationDatabase command.

Backup-SPConfigurationDatabase -Directory <Backup folder> -DatabaseServer <Database
server name> -DatabaseName <Database name> -DatabaseCredentials <PowerShell Credential
Object>

					  

2.3. Using the Restore-SPFarm cmdlet to Restore Only Farm Configuration Information

In SharePoint 2010, you do not have to restore the configuration database, because you have the ability to restore the farm configuration directly. You can restore the farm configuration from a backup that used either the Backup Content And Configuration Settings option or the Backup Only Configuration Settings option.

To restore a farm configuration, use the Restore-SPFarm cmdlet in a command similar to the one shown here.

Restore-SPFarm -Directory <RestoreShare> -RestoreMethod Overwrite -ConfigurationOnly

					  

You must use the –ConfigurationOnly parameter for this restore to complete successfully.

2.4. Using the Backup-SPSite and Restore-SPSite cmdlets

SharePoint 2010 allows you to back up and restore site collection information using both Windows PowerShell and STSADM. Backing up a site collection using Windows PowerShell provides a method for automated scripting and scheduling capabilities.

The following are the parameters available for use with the Backup-SPSite cmdlet to perform a site collection backup.

  • –Identity A valid URL (including the http portion) of the site collection that you want to back up.

  • –Path A valid location and file name of the backup file that will contain the backed-up site collection.

  • –Force Indicates to overwrite an existing file if the file name associated with the Path parameter already exists.

  • –NoSiteLock Specifies that the site collection is not set to read-only during a site collection backup. Using this parameter can lead to possible data corruption during the backup process. Use the default behavior of the Sitelock option to avoid the chance of data corruption. If there aren’t users accessing the site collection, you can safely specify this switch.

  • –UseSQLSnapshot Uses the content database snapshot when performing the backup.

In addition to these Backup-SPSite options, the Restore-SPSite cmdlet also has a set of parameters that you should be familiar with when restoring a site collection.

  • –GradualDelete Helps improve performance during the restore process if the site collection that you are restoring is 1 GB or larger. It will mark the site collection as deleted to prevent further access, and a SharePoint Timer job will gradually delete the data in the site collection instead of deleting the entire site collection at once; this way, it does not impact users accessing content in other site collections contained in the same database.

  • –DatabaseServer Specifies the server where the content database resides.

  • –DatabaseName Specifies the content database name. Use this parameter if you want to specify what content database you want the site collection restored in; otherwise, SharePoint will decide what content database it will be stored in.

To restore a site collection, use the Restore-SPSite cmdlet in a command similar to the one shown here.

Restore-SPSite -Identity <Site collection URL> -Path <Backup file>
2.5. Using the Export-SPWeb cmdlet

SharePoint 2010 allows you to back up sites, subsites, libraries, and lists using both Windows PowerShell and STSADM command-line tools. Performing a granular backup of these components using Windows PowerShell provides a method for automated scripting and scheduling capabilities.

The following parameters are available with the Export-SPWeb cmdlet to perform these granular backups.

  • –Identity A valid URL (including the http portion) or GUID of the site, list, or library that you want to export. Alternatively, you can use the Get-SPWeb cmdlet and pass the ID to Import-SPWeb using the pipeline.

  • –Path A valid location and file name of the backup file that will contain the exported SharePoint component.

  • –Force Indicates to overwrite the existing export file if the file name associated with the Path parameter already exists.

  • –IncludeUserSecurity Retains the user security settings.

  • –ItemUrl Specifies the URL of the SharePoint component being exported.

  • –HaltOnWarning Stops the export process when a warning occurs.

  • –HaltOnFatalError Stops the export process when an error occurs.

  • –NoLogFile Prevents the generation of an export log file.

  • –IncludeVersions Indicates which type of file and list version history is included in the export operation. The version types include the following.

    • LastMajor of all files and list items (default)

    • CurrentVersion refers to the current version, either last major or minor

    • LastMajorAndMinor refers to the last major and list minor version of files and list items

    • All includes all versions of files and list items

  • –NoFileCompression Disables file compression of the export file. If this parameter is used during the export, it must also be used during the import.

You cannot use SQL Server or Data Protection Manager (DPM) to export a site, library, or list. If you receive any errors, you can review them in the Failure Message column of the Backup and Restore Job Status page in Central Administration. You can also find additional details in the <file name>.export.log file at the UNC path that you specified in the Path option of the Export-SPWeb command.

2.6. Using the Import-SPWeb cmdlet

Although you can use Central Administration, Windows PowerShell, or STSADM to execute an export command, you can also use Windows PowerShell or STSADM to import data. You can import a site, library, or list from a backup of the current farm, a different farm, or from a read-only database after it has been attached in SQL Server. Importing lists or libraries is one method you can use to restore, move, or copy items or documents from one farm to another. However, you cannot import a site, list, or library from one version of SharePoint to another. For instance, you could not import content that had been exported from SharePoint Server 2007 into SharePoint 2010.

The Import-SPWeb cmdlet uses most of the same parameters as the Export-SPWeb cmdlet, except that the IncludeVersions options are replaced with UpdateVersions, which offers the following three choices.

  • Append Appends incoming content to existing content (default).

  • Overwrite Overwrites existing content.

  • Ignore Does not perform any action.

You can import a site, library, or list by using the Import-SPWeb cmdlet in a command similar to the one shown here.

Import-SPWeb -Identity <List or Library ID> -Path <Export filename>

2.7. Sample Windows PowerShell Backup and Restore Commands

The following are examples of different Windows PowerShell commands you can use to back up and restore various components of your SharePoint environment.


Note:

ON THE COMPANION MEDIA The following sample commands are also included on the companion media within the file SharePointPowerShellBackupandRestoreCmdlets.txt.


  • The following Windows PowerShell commands can be used perform a complete farm backup followed by a restore.

    Backup-SPFarm -Directory \\App01\SharePointBackups -BackupMethod Full
    Restore-SPFarm -Directory \\App01\SharePointBackups -RestoreMethod New

  • The following Windows PowerShell commands can be used to back up and restore a service application.

    Backup-SPFarm -Directory \\App01\SharePointBackups -BackupMethod Full -Item "Excel
    Services"
    Restore-SPFarm -Directory \\App01\SharePointBackups -RestoreMethod New -Item
    "Excel Services"
    
    					  

  • The following Windows PowerShell commands can be used to back up and restore farm configuration information only.

    Backup-SPConfigurationDatabase -Directory \\App01\SharePointBackups
    Restore-SPFarm -Directory \\App01\SharePointBackups -RestoreMethod Overwrite
    -ConfigurationOnly
    
    					  

  • The following Windows PowerShell commands can be used to back up and restore your SharePoint content databases.

    Backup-SPFarm -Directory \\App01\SharePointBackups -BackupMethod Full -Item
    ContosoPortal
    Restore-SPFarm -Directory \\App01\SharePointBackups -RestoreMethod New -Item
    ContosoPortal
    
    					  

  • The following Windows PowerShell commands can be used to back up and restore a site collection.

    Backup-SPSite -Identity http://App01/Sites/ContosoPortal -Path \\App01\
    SharePointBackups\PortalSiteCollection.bak -Force
    Restore-SPSite -Identity http://App01/Sites/ContosoPortal -Path \\App01\
    SharePointBackups\PortalSiteCollection.bak -Force

  • The following Windows PowerShell commands can be used to export and import a subsite, list, or library.

    Export-SPWeb -Identity http://App01/Sites/ContosoPortal/ -Path \\App01\
    SharePointBackups\SharedDocuments.bak -Itemurl "Shared Documents" -Force
    Import-SPWeb -Identity http://App01/Sites/ContosoPortal/ -Path \\App01\
    SharePointBackups\SharedDocuments.bak -Force -IncludeUserSecurity
 
Others
 
- Microsoft Lync Server 2010 : Director Installation (part 2) - Install Server
- Microsoft Lync Server 2010 : Director Installation (part 1) - Prerequisites, Create Director Pool
- Microsoft Lync Server 2010 : Director Overview
- Configuring Windows Server 2008 Active Directory : Creating Objects in Active Directory (part 4) - Finding Objects by Using Dsquery
- Configuring Windows Server 2008 Active Directory : Creating Objects in Active Directory (part 3) - Finding Objects in Active Directory
- Configuring Windows Server 2008 Active Directory : Creating Objects in Active Directory (part 2) - Creating a Group Object, Creating a Computer Object
- Configuring Windows Server 2008 Active Directory : Creating Objects in Active Directory (part 1) - Creating an Organizational Unit, Creating a User Object
- Exchange Server 2010 : Standards and Protocols - Active Directory: The Foundation of Exchange 2010
- Exchange Server 2010 : Standards and Protocols - Components of an Email System, Defining the Standards
- Installing Exchange Server 2010 in an Exchange Server 2003 environment (part 2)
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us