Scheduling STSADM SharePoint 2007 backup Strategy using Windows Task Scheduler

There are various third party SharePoint Product available in the market to do detailed backup of SharePoint site. But not all the project/Organisation can afford a third party product.

There are two kinds 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]

STSADM command line option is more reliable compare to SharePoint CA backup.

I have created this script creates which takes daily backup of a site collection. I have found few more script online and many of them didn’t work for me. The script does the following

  1. Determine the lock status – (This is for sites which is large in size If any changes made to the site collection during the backup process, the backup can become corrupted. The preferred approach would be locking the site collection using the Setsitelock command of STSADM till the backup process is complete. Once the backup process completes, reset the site collection to its default state)
  2. Locks the site collection
  3. Creates a file name using current date
  4. Creates backup
  5. Unlock the site collection


@echo off


@echo This script will backup your site: [Site Name]


cd c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

@echo locking site collection before the backup process starts

@echo off

stsadm -o getsitelock -url http://<Your Site Collection>

stsadm -o setsitelock -url http://<Your Site Collection> -lock readonly

@echo site collection is now locked

@echo off

stsadm -o backup -url http://<Your Site Collection> -filename C:\Back\Backup_%date:~-4,4%%date:~-7,2%%date:~4,2%.bak -overwrite

@echo backup completed

@echo off

stsadm -o setsitelock -url http://<Your Site Collection> -lock none

@echo Site lock removed

Copy the above code and do the necessary changes and Save it as 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.

This entry was posted in SharePoint 2007, Technical Issue SP2007 and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s