Click here to Skip to main content
13,862,357 members
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 25 Jul 2007
Licenced CPOL

SharePoint Backup

, 25 Jul 2007
Rate this:
Please Sign up or sign in to vote.
A SharePoint backup utility.


Typically, SharePoint backup is performed using the stsadm utility. Unfortunately, after setting up STSADM.exe to backup a SharePoint site, the backup directory will keep growing daily. The SPBackup utility eliminates the manual weekly task of removing old backups. It eliminating old backups from the file system and removes the backup references from the history log file (spbrtoc.xml).

Using the code

The utility performs a backup by calling the stsadm utility.

rFilename = rbinFolder + @"\stsadm.exe";
rArguments = "-o backup -directory " + rDirectory + " -backupmethod full";
Process proc = Process.Start(rFilename, rArguments);

After the backup is complete, the utility parses the spbrotoc.xml file to determine the number of backups present in the backup folder. If the number exceeds a defined maximum limit (which is passed as a command line argument), the old backups are removed from the file system and the history log (spbrtoc.xml) is updated.

string rHistoryFile = rDirectory + @"\" + "spbrtoc.xml";
XmlDocument doc = new XmlDocument();
doc.Load(rHistoryFile);XmlNodeList nodelist = 

if (nodelist.Count > nMaxBackups)
    XmlNode node = doc.SelectSingleNode("/SPBackupRestoreHistory");
    while (node.ChildNodes.Count != nMaxBackups)
        XmlNode Directorynode = node.LastChild.SelectSingleNode("SPDirectoryName");
        // Delete folder 
        Directory.Delete(rDirectory + @"\" + Directorynode.InnerXml, true);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Simon Bonello
Malta Malta
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralWorks great! Pin
bvermilion9-Jan-09 6:34
memberbvermilion9-Jan-09 6:34 
GeneralThanks. Great help! I added it to Pin
dknyoli17-Jun-08 3:34
memberdknyoli17-Jun-08 3:34 
Generalgetting error.... Pin
Bh@nu29-Aug-07 1:54
memberBh@nu29-Aug-07 1:54 
GeneralRe: getting error.... Pin
Simon Bonello29-Aug-07 2:42
memberSimon Bonello29-Aug-07 2:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190214.1 | Last Updated 25 Jul 2007
Article Copyright 2007 by Simon Bonello
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid