AndyGett
Andy Gettings is the president of Bullseye Consulting which develops and manages customized SharePoint applications and other software and databases for businesses. More
Microsoft Certified Technology Specialist

Microsoft Office SharePoint Server 2007 Configuration


RSS Feed Feed your read!

Archives

July 2008 (12)
August 2008 (1)
September 2008 (1)
October 2008 (2)
January 2009 (2)
April 2009 (1)

Links

Archive
Archive (Calendar)
@AndyGett Twitter
AndyGett LinkedIn
Bullseye Consulting

Tag Cloud

Family, M4300, Recreation, SharePoint, Technology, Virtualization,

SharePoint Backup Batch File 

Tags:

I have tweaked a quick backup method over several development projects. This is the current iteration, and works well for my needs in both WSS and MOSS:

@set spSite=http://wss01

@set spPort=7022

@set FileNamePrefix=GFam

@set targetPath=C:\Projects\GFam\Backup

@set targetPath2=\\tsclient\C\Dox\Dev\GFam\Backup

 

@set MONTH=%DATE:~4,2%

@set DAY=%DATE:~7,2%

@set YEAR=%DATE:~12,2%

 

@set FileName=%targetPath%%FileNamePrefix%%spPort%_%YEAR%%MONTH%%DAY%.bak

@set spURL=%spSite%:%spPort%

 

c:

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

Stsadm -o backup -url %spURL% -filename %FileName% -overwrite

@if "%targetPath2%"=="" goto finish

 

copy %FileName% %targetPath2%

 

:finish

pause

 

This creates a file named something like GFam7022_080718.bak, based on the parameters at the top and the current date. The params are

  1. spSite – This is the domain of the SharePoint site
  2. spPort – This is the port. If the URL does not need a port number, use 80 here.
  3. FileNamePrefix [optional] – A prefix can be a handy way quickly identifying the source site when browsing backup files.
  4. targetPath – This is where the file is backed up to. It needs a closing backslash "\"
  5. targetPath2 [optional] – I am nearly always RDP'ed into a server for development, and sometimes I find it useful to copy the backup file to my local machine. This could also be a file share or whatever.

To restore, use command line stsadm from in the 12-hive, e.g.,

Stsadm -o restore -url http://gfam.com:7022 -filename C:\backups\GFam7022_080718.bak –overwrite

Possible improvements

  1. Instead of copying to targetPath2, set up a command-line FTP. I currently FTP the backup to the production server by hand, but pretty soon we'll go completely live on the server after. I wonder if it is possible to use \\tsclient\c\... to point back to the local machine for an input file to keep the login off the server, e.g.,
    ftp -s://tsclient/c/dox/ftpLogin.in ftp.gfam.com
  2. Currently, I just create a new batch file for each new project. I suppose I could parameterize it, and call a single instance of this batch file from another batch file, something like
    call spBackup http://wss01 7022 GFam ...
  3. Omit the "http://" from spSite, and default FileNamePrefix to its value.
 
Posted by AndyGett on 18-Jul-08
1 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
 

Links to this post

Comments

Name:
URL:
Email:
Comments: