Wednesday, October 17, 2007

SharePoint V3: Stsadm.exe Backup Script

Create Backups Directory
Create a backup directory for storing the scheduled SharePoint backups (e.g. c:\backupsharepoint)

Create Bat File Directory
Create a directory for storing the backup script file (e.g. c:\scriptssharepoint)

Create Bat File
Create a bat file using the code below, modified for your environment. Use UNC paths when using in a server farm environment.

@echo off
echo ====================================================
echo Backup Script For Office SharePoint Server 2007
echo ====================================================
cd \program files\common files\microsoft shared\web server extensions\12\bin

@echo off
stsadm.exe -o backup -url http://servername -filename c:\backupssharepoint\backupsharepoint.dat -overwrite
@echo off
echo completed

Schedule bat file
Schedule the backup to run frequently, during off peak hours.

Open Start > Programs > Accessories > System Tools > Scheduled Tasks
Add a Scheduled Task

Scheduled Task Welcome Screen, Click Next
Click the program you want Windows to run, Click Browse
Select the backupsharepoint.bat file you created (e.g. c:\scriptssharepoint\backupsharepoint.bat)
Name the task, Schedule it (e.g. Daily)
Start Time, Frequency, Start Date
Username and Password (use a domain user account that has proper permissions and non expiring password )

Verify Backups
Keep the backup directory secure. Monitor the job to ensure the job is running properly. Perform test restores from the backup files.

Click Here if you need similar instructions for SharePoint Portal Server 2003.


Anonymous said...

How do you do test restores when the backup only lets you restore it to the original source?

Nicholas Bisciotti said...

You are not limited to restoring to the original source. You can restore the site collection backup (.dat file) to an alternate web application by specifiying a different web application URL in the stsadm.exe command.

Jonathan Stanton said...

I want to run this script under a different username/password.
I realise I will have to grant that user admin rights but do you know what rights and where do I need to add them.

Many thanks

Blog Archive