Creating a SharePoint 2007 Backup Strategy using STSADM commands complimented by Windows Scheduled Task (AT) commands
Synopsis:
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.
[1] 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
[2] 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
What an easy script to tuck away in the admin toolkit. Thanks!
Comment by Deanna McNeil | February 17, 2010 |
Thanks Deanna… I did some research before putting it together, most of which came from Jose Barreto and some bat file helper site… like Hillary says.. “…it takes a village…”
Comment by fabiangwilliams | February 17, 2010 |
Awesome Job Fabian – Thank you
Comment by Venkat | February 17, 2010 |
Thanks man.. bookmark it, guarantee you will use it from time to time..
Comment by fabiangwilliams | February 17, 2010 |
Great article Fabian! Very good Job. Thanks!
Comment by Vincenzo | February 18, 2010 |
Is it possible to use the sitelock switches w/ stsadm.exe and [free] WSS3? We’re backing up a large farm w/ stsadm.exe and running into file locking probs when copying the backup to another server via scheduled task. Here’s our .bat file:
e:
rmdir /s/q e:\backups\spbr0000
cd e:\backups
del /s/q/f *.*
c:
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
stsadm.exe -o backup -directory “e:\Backups” -backupmethod full
Thanks for any insight.
Comment by WMC | April 16, 2010 |
Yes you can but with Service Pack 2 you dont need to anymore, it is automatic
Comment by fabiangwilliams | April 16, 2010 |