I mentioned in my previous post that I was doing a presentation at the local SharePoint user group meeting and wanted to create a simple command to demonstrate what is involved with creating custom stsadm extensions. The first command I created (gl-backupsites) turned out to be too complex for demonstration purposes so I took another approach and decided to show how to simply wrap an existing command in order to extend it. What I chose to do was to wrap the existing out-of-the-box backup command and simply add an "-includeiis" parameter. I called my new command gl-backup.
The code is pretty simple. I basically just reproducing the parameters from the built-in command which I just grabbed with the help of Reflector. I then just loop through the parameters in order to build the call to the built-in command. Once the built-in command is finished running I grab the generated XML index file and locate the folder in which the backup was stored. I then use this folder to store the IIS settings:
The syntax of the command can be seen below:
C:\>stsadm -help gl-backup stsadm -o gl-backup For site collection backup: stsadm.exe -o gl-backup -url <url> -filename <filename> [-overwrite] For catastrophic backup: stsadm.exe -o gl-backup -directory <UNC path> -backupmethod <full | differential> [-item <created path from tree>] [-percentage <integer between 1 and 100>] [-backupthreads <integer between 1 and 10>] [-showtree] [-quiet] [-includeiis]
Here's an example of how to backup a farm and include the IIS settings:
stsadm -o gl-backup -directory c:\backups -backupmethod full -includeiis