3. Using STSADM
SharePoint 2010 still
supports the use of Stsadm.exe for managing your backups. Although the
recommended command-line tool for managing your SharePoint farm backups
and restores is now Windows PowerShell, STSADM has been enhanced to
support all new backup and restore functionality supported in SharePoint 2010. Similar to Windows PowerShell, you can script and schedule STSADM
commands to perform backups. Use STSADM commands until you have time to
learn the Windows PowerShell commands for SharePoint that perform
backup tasks. The backups that you perform using STSADM can be restored
using Central Administration or Windows PowerShell.
Your SharePoint 2010
disaster recovery plan can include Windows PowerShell or STSADM commands
that can be used to back up and restore your SharePoint content. All
backup and restore options available in the Central Administration
Backup And Restore interface are also available using STSADM. In fact,
similar to Windows PowerShell, STSADM commands provide some additional
functionality for performing backups and restores of SharePoint
information that aren’t available within Central Administration.
STSADM backups can be grouped into two categories: catastrophic backups and site collection backups. Catastrophic backups are identified by backup commands that include the –BackupMethod
parameter and can be used to back up most everything in SharePoint,
including the entire farm, Web applications, service applications, and
your content databases. Site collection backups are backups that you
perform for a specific site collection, indicated by specifying the –Url parameter when issuing the STSADM backup command.
The following is an example of a STSADM farm level backup in its simplest form.
stsadm.exe -o backup -directory \\backupservername\backups\ -backupmethod full
3.1. Catastrophic Backups
Backing up SharePoint
information using STSADM provides a method for automated scripting and
scheduling capabilities. It will also prevent SPTimer job errors and
assure that your backups won’t fail. The following are some of the most
common parameters used with STSADM commands to perform catastrophic
backups.
–Directory <UNC path> The UNC path should be created on a server in the same domain, with share and security permissions as previously defined.
–BackupMethod <Full | Differential>
At least one full backup must be performed on a new farm or when adding
a new Web or service application before you can make a differential
backup. You must use the most recent differential backup when restoring
content.
–Item
This parameter allows the backup of a single SharePoint component. You
must enter information exactly as it exists or the backup will fail. The
following is an example of how to use the –Item parameter if you want to back up a portal that is a Web application you want to back up.
stsadm -o backup -directory \\backupservername\backups -backupmethod full -item
"Farm\Windows SharePoint Services Web Application\Portal"
–Percentage The –Percentage
parameter controls the granularity of on-screen feedback as the
operation progresses. If you are scheduling the script to run, this is
of no value.
–BackupThreads
If you have a large implementation and require significant throughput
on your backups, this parameter 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. By default the number of –BackupThreads is 1, the recommended
number is 3, and the maximum number is 10.
–ShowTree The –ShowTree
parameter is primarily used to define single items that you want to
back up, but it is also useful to access a comprehensive view of your
server farm.
–ConfigurationOnly This parameter will back up farm configuration information only.
–Quiet Use this parameter to suppress output.
–Force This parameter overwrites content at the destination if a file with the same name already exists.
3.2. Catastrophic Restores
You use restore commands to
retrieve information from your backups that will replace the content
databases that are currently in SQL Server.
You do not need to change
anything in your backup procedure if you plan to do a restore, because
by default the same source media is used during the restore operation
that was used during the backup operation. The following parameters are
used when restoring content to your farm.
–Directory <UNC path> Specifies the directory that contains the backup data you want to restore.
–RestoreMethod <Overwrite | New>
Using overwrite restores content over existing data, and all the
original content is lost. The New option allows you to restore
information to a different location than where the backup was performed.
–BackupID <ID from backuphistory> The ID information you need to use this parameter can be found with the following command.
stsadm.exe -o backuphistory -directory <UNC path> -backup
–Item Restores a single SharePoint component.
–Percentage Shows the granular process status of the restore procedure.
–RestoreThreads
If you have a large implementation and require significant throughput
on your restores, this option can increase the amount of processing time
allocated to the restore process.
–ShowTree Shows the content that is available for restores.
–SuppressPrompt Uses the current user name and password for user name/password prompts.
–Username Specifies a user name for a Web application process account.
–Password Specifies a password for a Web application process account.
–NewDatabaseServer
Specifies the name of a new database server to which you will restore
your backup when you are restoring content from one database server to a
different database server.
–Quiet Suppresses output.
3.3. Site Collection Backups
Backing up site collection information using STSADM
provides a method for automated scripting and scheduling capabilities.
The parameters are available when using Stsadm.exe for site collection
backups.
–Url Specifies a valid URL (including the http portion) of the site collection that you want to back up.
–FileName Specifies a valid file name and the location of the backup file that will contain the backed-up site collection.
–OverWrite Indicates that the backup should overwrite the existing file if the file name already exists.
–NoSiteLock
Specifies that the site collection lock is not set to read-only during a
site collection backup. Using this parameter can lead to possible data
corruption during the backup process.
–UseSQLSnapshot Uses the content database snapshot when performing the backup.
3.4. Site Collection Restores
Restoring site
collections using STSADM provides a method for automated scripting and
scheduling capabilities. The following parameters are available when
using Stsadm.exe for site collection restores.
–Url Specifies a valid URL (including the http portion) of the site collection that you want to back up.
–FileName Specifies a valid file name for the backup file that will contain the backed-up site collection.
–OverWrite Indicates that the restore should overwrite the existing file if the file name already exists.
–HostHeaderWebApplicationURL Used when restoring a Web application.
–GradualDelete
Marks the site collection as deleted to prevent further access while a
SharePoint Timer job called Job-gradual-site-deletion deletes the data
in the site collection gradually.
3.5. Site and Subsite Exports
Exporting sites and subsites using STSADM
provides a method for automated scripting and scheduling capabilities.
The following are the most common export parameters available when using
Stsadm.exe to export sites or subsites.
–Url Specifies a valid URL (including the http portion) of the site that you want to export.
–FileName Specifies a valid file name for the backup file that will contain the exported site.
–OverWrite Indicates that the export should overwrite an existing export file if it already exists.
–IncludeUserSecurity Retains the user security settings.
–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.
–Versions
Indicates which type of file and list version history is included in
the export operation. The version types include the following.
1 = Last major version for files and list items (default)
2 = Current version, either last major or minor
3 = Last major and list minor version for files and list items
4 = All versions for files and list items
–NoFileCompression Disables file compression of the export file.
–Quiet Suppresses the output of export progress.
–UseSQLSnapshot Use the content database snapshot when performing the export operation.
3.6. Site and Subsite Imports
Importing sites and subsites
using STSADM provides a method for automated scripting and scheduling
capabilities. The following are the parameters that are available when
using Stsadm.exe for site collection imports.
–Url Specifies a valid URL (including the http portion) of the site that you want to import.
–FileName Specifies a valid file name of the backup file that contains the imported site.
–IncludeUserSecurity Retains the user security settings.
–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.
–ActivateSolutions Activates all solutions found during import.
–IncludeUserCustomActions Allows the following options for how to handle custom actions found during import.
–Versions
Indicates which type of file and list version history is included in
the export operation. The version types include the following.
1 = Add new versions to the current file (default)
2 = Overwrite the file and all its versions
3 = Ignore the file if it exists on the destination
–NoFileCompression Disables file compression of the export file.
–Quiet Suppresses the output of export progress.
3.7. Sample STSADM Backup and Restore Commands
The following are examples of different STSADM commands you can use to back up and restore various components of your SharePoint environment.
Note:
ON THE COMPANION MEDIA These commands are included on the companion media within the file SharePointStsadmBackupandRestoreCommands.txt.
The following STSADM commands can be used to perform a full farm backup followed by a restore.
stsadm -o backup -url http://app01/ -directory \\app01\sharepointbackups
-BackupMethod Full -Quiet
stsadm -o restore -url http://app01/ -filename \\app01\sharepointbackups
-Overwrite
The following STSADM commands can be used to back up and restore configuration information only.
stsadm -o backup -url http://app01 -directory \\app01\sharepointbackups
-configurationonly -quiet
stsadm -o restore -url http://app01 -filename \\app01\sharepointbackups
-configurationonly -quiet
The following STSADM commands can be used to back up and restore a service application.
stsadm -o backup -directory \\app01\sharepointbackups -quiet -backupmethod full
-item "Excel Services"
stsadm -o restore -directory \\app01\sharepointbackups -item "Excel Services"
-quiet
The following STSADM commands can be used to back up and restore a site collection.
stsadm -o backup -url http://app01/portalsitecollection -filename \\app01\
SharePointBackups\portalsitecollection.bak -overwrite
stsadm -o restore -url http://app01/portalsitecollection -filename \\app01\
SharePointBackups\portalsitecollection.bak -overwrite
The following STSADM commands can be used to export and import a subsite, list, or library.
stsadm -o export -url http://app01/sites/contosoportal/Shared%20documents
-filename \\app01\sharepointbackups\SD.bak -quiet -overwrite
stsadm -o import -url http://app01/sites/contosoportal/Shared%20documents
-filename \\app01\sharepointbackups\SD.bak -quiet