Creating a SharePoint 2007 Backup Strategy using STSADM commands complimented by Windows Scheduled Task (AT) commands
I am on a project where we will have to rely on the out of box (OOB) Backup Strategies from Office SharePoint Server. I am wearing my IT Pro hat, but the developer in me… says when you do something once… Automate it for future use, Blog it so you can remember it…. SO here goes.. There are two flavors of OOB Backup Strategies in Office SharePoint Server 2007:
1. Using Central Administration –> Operations –> Backup and Restore
2. Using STSADM –> – o backup –url [site path] –filename [where to save the file]
The Central Administration route is, in my opinion an ineffective way to do backups if your goal is to be a long term strategy; it is a one-time deal through a wizard with limited options. Certainly if you are in need to do a backup because of a pressing circumstance, this is in-fact a viable option, but outside of that, STSADM provides more flexibility and it may be scripted and scheduled for future recurring operations.
HOW TO: Implementing a Backup Strategy with OOB STSADM commands
STSADM Backup Syntax:
For site collection backup
stsadm -o backup
Things to look out for when using STSADM to perform backups
As your site grows, logically does your content databases, and if you are employing STSADM as the tool for backup, a bi-product of that will be “longer backup times”. If your environment will be taking longer to backup, your risk of someone updating a file/document/asset as you are performing your backup increases; as a result if a backup is in running and a file is open, that backup is at risk of failure. How do we combat that problem? We use yet another STSADM command to lock the Site in effect the database to read-only; we do this with the SiteLock command, there are two in particular, getsitelock and setsitelock see below for the full command syntax.
stsadm -o getsitelock
stsadm -o setsitelock
Automate your Backup Solution
Certainly you can navigate to the SharePoint 12-Hive and execute these commands as a single action; however, a more consistent action is to script the job with error handling and user feedback.
Script your Backup
Save the above to a .bat file in a preferred location.
Automate your Backup
Create a new Windows Scheduled Task by going to Start–> Control Panel –> Scheduled Tasks –> Add Scheduled Task
Follow the wizard and schedule the .bat file created above to run at a frequency of your own choosing.
 A complete reference of STSADM commands are located on Jose Barreto’s blog http://blogs.technet.com/josebda/archive/2007/03/22/complete-reference-of-all-stsadm-commands-with-options-in-moss-2007.aspx
 Example of creating the filename so it changes daily and thus does not have to overwrite itself. http://www.zorbathegeek.com/153/batch-file-to-append-date-to-file-name.html