Leveraging the power of the new SharePoint 2010 Management Shell, this powerful PowerShell script will perform a SharePoint farm/site backup based on your requirements as stipulated in an accompanying params XML file.
Click here for supporting documentation: Preparing for & Configuring the SharePoint
(2010) Farm Backup Script (PDF).
Please take the time to read through the comments in the script itself as this will prove to be quite informative.
UPDATE: Version 2.3 Now available for download.
This script was written for SharePoint 2010 administrators who perform backups of their farms utilising the out of the box (OOTB) backup and restore PowerShell cmdlets and who may or may not have the luxury of protecting their farms with one of the 3rd party
- Ability to perform FULL or DIFF backup of farm.
- Ability to perform CONFIG ONLY backup of farm.
- Ability to perform backup of ALL sites in farm.
- Ability to perform backup to local storage or remote (Network Share).
- Ability to stipulate FULL and DIFF backup schedule.
- Ability to backup & compress GAC/IIS/14Hive and ULS logs.
- Performs 'House-Keeping' and deletes old backup files & logs based on retention period.
- Detailed error handling. In the event the script exits prematurely an email is sent.
- Reports if there are errors or warnings during the backup.
- Reports start and end time for backup is logged to backup log and application log.
- Duration of backup included is logged to backup log and application log.
- Ability to specify the number of threads used for the backup.
- Specify different email address(es) for success or failure reporting.
(0) FULL: Sun
(1) FULL: Selected day(s) as stipulated in params.xml
DIFF: Remaining Days
(2) FULL: Everyday
- Check to ensure farm meets criteria to allow for -UseSqlSnapshot
- Include/Exclude MySites from Sites backup.
Future enhancements planned:
- Determine amount of disk space required for the backup and storage available. (Added v1.1)
- Creation of Share with required permissions if not present. (Coming in v3.0)
- Backup of individual web.config files (per Web Application/Zone). (Added v1.2)
- Backup (export) of solutions (wsp) from solution gallery. (Added v2.2)
- Granular storage check based on selected backup options. (Added v2.2)
- Allow for inclusion/exclusion of MySites in site backup. (Added v2.2)
- GUI to create/edit XML and create scheduled task. (Coming in v3.0)
- Inclusion of FAST Search backup. (Coming in v3.0)
- Compatibility with SharePoint 2013. (Coming in v3.0)
- SharePoint Server 2010/SharePoint Foundation 2010.
- PowerShell v2.0.
- Local attached storage or network storage.
- Shared folder (at this time this must be created manually).
When backing up your SharePoint 2010 farm you must take into account the following:
- Central Admin app pool account must have read/write access to the location of the backups.
- SQL Service account must have read/write access to the location of the backups.
- When running a farm backup from STSADM or Windows PowerShell, the account you're running it as must have read/write access to the location of the backups.
- The location must be accessible from the SharePoint machine the backup is running on.
- The location must be accessible from the SQL instance that SharePoint is trying to back up.
Note: This is why all the examples are UNCs, \\server\share and not local paths,
- Create a directory for the files (e.g. C:\Farm-Backup)
- Place the Farm-Backup.bat, Farm-Backup.ps1 and params.xml files in the directory.
- Edit the XML configuration file with desired options.
- To run the script execute the Farm-Backup.bat.
- To automate the time and frequency of the script, schedule the script in Task Scheduler.
- At present this script MUST be run on a SharePoint server.
- At present the Backup Share must be manually created.
IMPORTANT: If you host Central Admin and UPS on the same server, then you MUST ensure your farm admin account remains in the local admins group on the server running the UPS and an IISRESET is performed following the backup. For
There are a plethora of articles/blogs/whitepapers available that I have read and used as reference. Additionally there are quite a few permutations of PowerShell backup scripts available that I have seen and taken inspiration from that it would be impossible
to include them all here.
Brian Lalancette of Navantis. who kindly provided the
Out-Zip method included in the script.
Incidentally, if you haven't seen his script yet you really should:
Visit my blog: http://www.darrenmarsden.com