SharePoint Backup Scripts Created by: Steve Clarke Copyright (c) 2005 Infotech Canada Inc. (http://www.infotechcanada.com) (See script files for license.) Included files: sp_backup.cmd - Main backup script sp_backup.bks - NTBackup backup set file sp_backup_sched.cmd - Create scheduled daily backup task README.TXT - This file INTRODUCTION ============ I created this script to address the complexity involved in performing SharePoint backups. The basic SharePoint backup regimen involves: - Backup up SharePoint Portal Server using the SPSBackup.exe utility provided by Microsoft. - Backup individual site collections (if required) - Backup System State using ntbackup.exe - Backup miscellaneous files not covered by SPSBackup.exe, for example: - \Inetpub - \Program Files\Common Files\Microsoft Shared\web server extensions\60\CONFIG\ - \Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\ - \WINDOWS\system32\LogFiles\ - Backup IIS Metabase - Backup SQL Server - Backup your own custom apps/web parts - Backup third party custom apps/web parts This script addresses using SPSBackup.exe, ntbackup.exe to backup System State and miscellaneous files, and IIS Metabase. It does not backup individual site collections, your SQL Server databases, nor your custom apps/web parts, unless you specify them in the ntbackup.exe portion. WHAT IT DOES ============ This script will backup your SharePoint files to a network share that you specify. It will get the hostname of the server and create a folder on your backup share using that hostname. It will backup your portal using SPSBackup.exe and place the files in the SPSBackups folder. It will backup your System State, and other misc files in the MiscFiles folder. The backup process will be logged in the root backup destination folder. i.e. \\server\sharename\hostname\backup*.log Three events will be added to your Application Event Log from source sp_backup.cmd: 1. An Information event, ID of 100 notifying that the backup script has begin its run. 2. An Information or Error event, ID of 1 and 2 respectively, notifying whether the backup script was successful or failed. 3. An Information event, ID of 200 notifying that the backup script has finished its run. You may utilize these events to create Event Rules in Microsoft Operations Manager, or use the command-line eventtriggers tool to create custom handlers. When complete, the backup log will be e-mailed to the recipients specified in the script configuration. PERMISSIONS =========== Ensure that your SharePoint service account, and your SQL Server service account have Modify permissions to your backup share, both at the share and filesystem level. For more information regarding the required permissions for SharePoint backups, see the SharePoint Resource Kit, Chapter 28. http://www.microsoft.com/technet/prodtechnol/sppt/reskit/c2861881x.mspx INSTALLING ========== 1. Copy the provided files into an appropriate location. I like to create a C:\Utils folder on each computer, and create a folder under that called sharepoint_backup to hold the scripts. 2. Ensure that the command-line mailer, blat, is available somewhere in your path. You can obtain the latest version of blat from: http://www.blat.net 3. Configure sp_backup.cmd by editing the file. Look for the section near the top entitled "@@ USER CONFIGURABLE SETTINGS". Set the various parameters according to the comments provided. Ensure that you do not leave a space after the set=, as batch files do not allow this space. 4. Edit sp_backup.bks. This is the ntbackup.exe Backup Set File (.bks). It is a simple text file listing a set of paths to folders that you want ntbackup.exe to include. Do not remove the line SystemState, unless you want to exclude the System State backup. Alternately, you may run the NT Backup GUI to load, edit, and save the backup set file. 5. Now you should be ready to do a test run of the backup script. Keep in mind that if you run the script under your own account, you may have a higher privilege level than the service that you choose to schedule the backup under. Take this into account when verifying the backup script. Additionally, even if you test the script in interactive mode as the user that you will run the scheduled task as, you may still receive "Access is Denied" errors on the scheduled task run. If you do, please see the following Microsoft Knowledge Base article: http://support.microsoft.com/?kbid=867466 6. Once you are comfortable that the script is running, you can run the sp_backup_sched.cmd script to schedule a daily run of the backup script. Simply run the script and you will be prompted for settings. FUTURE PLANS ============ - Tie in site backup script to perform individual site backups - Provide script to automate creation of automated SQL Server backups - Clean up my event triggers scripts to allow easy creation of event log monitoring of backups and other SharePoint related monitoring. - Implement better ntbackup monitoring -- ntbackup is known to not handle errorlevels properly. Possible options include monitoring ntbackup using event logs (eventquery script), or using RoboCopy for all but System State backup. VERSION HISTORY =============== September 10, 2005 - v1.0 - Initial release.