Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backing up SharePoint & script/batch file??

Status
Not open for further replies.

jdnorris

Technical User
Jul 13, 2004
76
US
Does anyone have or know where I can get a script/batch file to use for backing up SharePoint. I want to backup SharePoint with stsadm to a file located on the local drive and then I want our backup product to back that file up offsite. I'd like to have this script run daily replacing the old backup file. Has anyone done this? Is it possible?
 
Hi,

To create a script that backup your sites using stsadm.exe is a very simple task. If you have one virtual website then you just need one line (the actual command line with backup parameter for stsadm). Put it in a batch file and run it as a scheduled task. How to use the stsadm tool is described in The Administrators guide (which I assume you already have!)

Below is how I have done it for backing up all my virtual websites (have over 50 of them) so I just made a simple script.

I created two script files and one text file
Textfile is namned: sites.txt
It contains two columns, one is the address to the site without http:), like this: sharepointsite.com
the 2nd column contains the name I want for the backup file, like this: sharepointsite.dat


First script file I namned: backup.cmd
it contains:
DATE /T > BACKUP.log

FOR /F "TOKENS=1,2" %%i IN (sites.txt) DO CALL BACKUP_SITES.CMD %%i %%j

The 2nd file is namned: BACKUP_SITES.CMD
It contains the following:
@echo off

echo Start %1 >> backup.log
Time /T >> backup.log

call "C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN\STSADM.exe" -o backup -url " -filename d:\backup\%2.dat -overwrite

echo Stop %1 >> backup.log
Time /T >> backup.log

There might be smarter ways of doing this, but if you only have one virtual website then you only need one single line.
I wanted to have a timestamp for each virtual website, both when backup started and when backup ended, so I know how long it takes to backup each site.

I just put the file i namned backup.cmd as a scheduled task to be run each night. Then our corporate backupsoftware take filebackup and puts it offsite to another server and onto backup tapes.

As I said there are more sophisticated scripts that can be done, but it just took me a couple of minutes to set this up and it works fine for me. I am however only using this stsadm as a secondary backup. I am using a 3rd party software for item-level backup, which can't be done with the stsadm tool.

Cheers,
Thomas




 
Thomas, thank you so much for the information. Are there in issues running the stsadmin during business hours? Will have any impact on the users and/or site? Anything I should be aware of before running it? Thanks again for the information.
 
You are welcome. I am running my backup jobs outside of business hours, just to make sure it does not affect performance. I would say it depends on how much data and how many sites you are backing up and also how many concurrent users you have using the sites.

I would recommend you to do the backups on non-office hours, just to make sure that you do not have any problems in getting all the data backed up properly.

Cheers,
Thomas







 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top