in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Andrew Noon's Blog

SharePoint, MOSS 2007, Information Architecture, Business Intelligence and other rambling

SharePoint 2003 Site Level Backup

Here's an extract from a backup guide I wrote for a customer a while back, it's designed to complement a full SQL backup plan but allows you to restore single sites or site collections so that you don't have to roll back the whole environment for the sake of one site / docuement.

The script is taken from MSFT best practice.

In order to perform a backup at site level, firstly a batch file must be created with the following content:

 cscript  c:\backup\scripts\stsadm_backup.vbs 

the contents of the stsadm_backup.vbs file should be similar to:

 Option ExplicitConst STSADM_PATH = "C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN\stsadm" Dim objFso, objFolder, objFiles, objFile, objShell, objExec, strResult, objXml, objSc, objUrl, strUrl, strFileName, strCmdSet objFso = CreateObject("Scripting.FileSystemObject")Set objFolder = objFso.GetFolder("C:\backup\")Set objFiles = objFolder.FilesWScript.Echo "Begin backup"  ' Delete all backup files currently present in the backup folder.  For Each objFile in objFiles  objFile.Delete(True)Next ' Retrieves all site collections in XML format.Set objShell = CreateObject("WScript.Shell")Set objExec = objShell.Exec(STSADM_PATH & " -o enumsites -url http://[server]/")strResult = objExec.StdOut.ReadAllWScript.Echo strResult ' Load XML in DOM document so it can be processed.Set objXml = CreateObject("MSXML2.DOMDocument")objXml.LoadXML(strResult)  ' Loop through each site collection and call stsadm.exe to make a backup.For Each objSc in objXml.DocumentElement.ChildNodes    strUrl = objSc.Attributes.GetNamedItem("Url").Text    strFileName = "C:\backup\" & Replace(Replace(strUrl, "http://", ""), "/", "_") & ".bak"    strCmd = STSADM_PATH & " -o backup -url """ + strUrl + """ -filename """ + strFileName + """"    WScript.Echo "Backing up site collection " & strUrl & " to file " & strFileName & " using the following command " & strCmd    objShell.Exec(strCmd)Next WScript.Echo "Backup of portal site collections successful" 

The resulting files can then be backed up to the relevant media and means that if a single site or site structure becomes damaged they can then be restored without affecting the ancillary sites on the server farm.

Comments

No Comments

Leave a Comment

(required )  
(optional )
(required )  
Add

About Andrew Noon

Technical Consultant Strengths  Microsoft Office SharePoint Server 2007  SharePoint Portal Server 2003  Windows SharePoint Services  Enterprise Content Management  Business Process and Workflow Skills  Microsoft .NET C#  SQL Server  ASP.NET  K2  Information Architecture Certifications  Microsoft Certified Professional (MCP)  FileNet Certified Professional  Sun Java Certified Professional

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts