Project Description
This script backs up everything you need for a full restore of your Windows Sharepoint Services (WSS) or Microsoft Office Sharepoint Server (MOSS).

Sites, 12-hive and IIS Metadata is compressed and saved on a userdefined central location. The XML configuration file contains the settings of one or more sitecollection backups with different backup/reporting parameters for each job.

Requirements
WSS 3.0 or MOSS 2007
Windows Powershell 1.0
Diskspace on local drive or network location.

Installation
  1. Make a directory for the files (e.g. C:\SPBackup) and copy the SPBackup.ps1 and SPBackup.xml files there
  2. Edit the XML configuration file with your environment parameters
  3. Configure the signing of your script for Windows Powershell to allow your script to run (see this article)
  4. Test-run the script from Windows Powershell with: C:\SPBackup\SPbackup.ps1 C:\SPBackup\SPBackup.xml
  5. Schedule the script in Windows Scheduled Tasks

Configuration
All configuration is done in the XML-file.

If you do not fill in the fromemail, tomail or smtpserver the script will not attempt to send an email but only report to the console.

If you do not fill in the iisencryptionpassword the script will use the machine encryption and the IIS Metadata is only usable on this server and not importable on other servers.

You can add as many sitecollections you want in the XML-file if they have unique IDs. The sample has two sitecollections defined.

XML Parameters (version 1.1)
catastrophicbackup: Set this value to 1 to perform a complete farm backup and 0 to skip this backuptype
catastrophicmethod: Set this to full or differential
sitecollectionbackup: Set this value to 1 to perform an individual backup of a site collection and subsites and 0 to skip this backuptype
sitecollectionurl: Set this to the site collection url you want to perform an individual backup of
hivebackup: Set this value to 1 to perform a backup of your 12-hive
hive: Path to your 12-hive (usually located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12
iisbackup: Set this value to 1 to perform a backup of the IIS Metadata and 0 to skip this backuptype
iisencryptopassword: Type a password here to make the IIS6 Metadata backup restorable on other servers
smtpserver: Type a smtp server to send mail through
fromemail: E-mail address to send from
backupdestination: Type a valid path for the backupfiles
backupdestinationmaxkeepdays: If set to 0 no files are deleted. Set another number to delete files older .zip/.backup-files. Full/differential backup files are NOT deleted (from spbackup version 1.2)

Notes
The powershell script can be scheduled using Windows Scheduler with the following command:
%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -command "& C:\SPBackup\SPBackup.ps1 'C:\SPBackup\SPBackup.xml'

If you need to restore your IIS6 Metadata on another server you must define an encryption password in your XML-file. Read more at the Microsoft articles here: Backup KB324277 Restore Technet.

Remember to set the correct share and NTFS security rights. When performing a complete backup the SQL Server service account and the Web Application Pool account must have modify rights to the backup destination. When performing individual site collection backup the Scheduled task account must have modify rights to the backup destination.

Known issues
*The script can only run locally on Sharepoint servers
*If the compression of 12-hive or IIS Metadata isn't finished before the script ends, the compression stops. Please adjust the Start-sleep in the end of the script to avoid this.

Thank you
A thank you to Bill English, his great book on Sharepoint Administration and excellent session at TechEd 2007. I would like to thank Todd Klintt for his post on backup considerations and Shadar Gvirtz for the blog on Sharepoint Powershell backup. For the script to compress the folders the Out-Zip project by Mike Hodnick was included and I thank him for that post.

Visit my blog for more technical Sharepoint articles: Jesper M. Christense Livespace

Donations are always welcome if you like the product and get something out of it. Please use the following link: Make a donation

Last edited Dec 16, 2008 at 10:59 AM by JesperMChristense, version 16