manual

45 www.microsoft.com/sharepoint
Scenario: Using Windows PowerShell to Script Backing Up All Site Collections
Individually
Jennifer is an overly cautious SharePoint administrator who doesn’t have complete faith
in the database backups that are being performed each night by her database
administrators. She would prefer that she had her own backups, just in case. Looking at
her options, she can do a full farm backup by using the user interface, but she doesn’t
want to VPN in every night at midnight to start the jobso that is out. She could set
up a Windows PowerShell script to do the farm backup each night by using
Backup-SPFarm and then schedule that by using Task Schedulerbut that backup is
best served for disaster recovery and that is what the database administrators are
protecting. So she settles on using a Windows PowerShell script that will take advantage
of the cmdlet Backup-SPSite to back up individual site collections. This will give her a
great deal of flexibility for recovery. The script she used is:
Get-SPWebApplications | Get-SPSite | ForEach-Object {$FilePath = “c:\backups\” +
$_.Url.Replace(http://,””).Replace(“/”,”-“ + “.bak); Backup-SpSite Identity $_ -path
$Filepath
Farm Backup and Restore
SharePoint Server 2010 has built in capabilities for backing up the entire farm to provide
recovery for a catastrophic failure. This interface can be accessed from within Central
Administration for ad hoc backups and recovery, or it can be scripted by using the
Windows PowerShell cmdlets Backup-SPFarm and Restore-SPFarm, respectively. A
new addition to the catastrophic backup scenario is the capability to do a configuration-
only backup.
The configuration-only backup outputs an XML file that can be used to restore all
settings in the farm. This could be used for recovery of the farm or to build a different
farm entirely by using the same settings. This is possible because all settings that are
backed up are nonmachine-specific.
Read-Only Databases
SharePoint Server 2010 has the ability to recognize read-only SQL databases. Whenever
SharePoint Server is connected to a SQL database that has been placed in read-only
mode, SharePoint Server will security trim all site collections in the database so that they
are read-only to all users, removing all add and edit functionality from the sites, even for