The most robust, free, plug-n-play solution I've found was this vbscript:
Option Explicit
' Email source address
Const strFrom = "[email protected]"
'Email destination address
Const strTo = "[email protected]"
' Mail server address
Const strMailserver = "smtp.host.com"
'Mail Server Schema
Const strSchema = "http://schemas.microsoft.com/cdo/configuration/"
Dim varWeekDay, loopCounter, sharepointProcess, NodeList, Node
Dim objShell, objWMIService, objXMLDoc, objEmail, objFSO
Dim strRegKey, strMOSSPath, strBackupLocation, SharPointBackupRestoreTable, strComputer
Set objShell = CreateObject("WScript.Shell")
' Create variable used to contain the name of day
varWeekDay = (WeekdayName(Weekday(date)))
' Obtain the path where stsadm is located on the server
strRegKey = objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Location")
'Sets stsadm folder string
strMOSSPath = strRegKey & "BIN\"
'sets backup folder string
strBackupLocation = "\\server\share$\" & varWeekDay
' Define the path to SharePoint Backup Restore Table file which contains
' crucial information regarding the outcome of the backup
SharPointBackupRestoreTable = strBackupLocation & "\spbrtoc.xml"
'*********************************************************
'Main Code Starts
'*********************************************************
'Deletes weekday folder only
Call deleteBackupFolder (strBackupLocation)
'Ensure the script runs in the SharePoint directory
objShell.CurrentDirectory = strMOSSPath
' Execute stsadm backup command
objShell.Run ("stsadm -o backup -directory " & strBackupLocation & " -backupmethod full")
' This Do loop checks the status of the backup process every minute.
' If the backup process hasn't completed within 60 minutes an email is sent to the
' Sharepoint administrator notifying him/her about this, otherwise an email is sent
' notifying the SharePoint Administrator of the outcome of the backup
Do
loopCounter = loopCounter + 1
If loopCounter > 60 Then
Call SendEmail("SharePoint Backup Process exceeded 60 minutes", "SharePoint backup process has been running for over 60 minutes. Please check progress of backup.")
End If
' Wait for 1 minute
WScript.Sleep 60000
' Check if the backup process (i.e. stsadm.exe) is currently running
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set sharepointProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'stsadm.exe'")
If (sharepointProcess.count) = 0 Then
' Backup process has ended therefore check the SharePoint Backup Restore Table to analyse the outcome of the backup
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load(SharPointBackupRestoreTable)
Set NodeList = objXMLDoc.documentElement.selectNodes("//SPErrorCount")
For Each Node In NodeList
If (Node.text) <> "0" Then
' Backup errors were generated
Call SendEmail("SharePoint Backup Process Failed", "SharePoint backup failed with errors. Please investigate backup logs")
Else
' No backup errors were generated
Call SendEmail("SharePoint Backup Process successfully completed", "SharePoint backup completed without errors - " & strBackupLocation)
End If
Next
Exit Do
End If
Loop
'Sends email with status of backups
Sub SendEmail (subject, body)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = subject
objEmail.Textbody = body
objEmail.Configuration.Fields.Item _
(strSchema & "sendusing") = 2
objEmail.Configuration.Fields.Item _
(strSchema & "smtpserver") = strMailserver
objEmail.Configuration.Fields.Item _
(strSchema & "smtpserverport") = 25
objEmail.Configuration.Fields.Update
On Error Resume Next
objEmail.Send
On Error GOTO 0
Call WriteEvent(subject,body)
End Sub
' Log the backup outcome to server application event log
Sub WriteEvent(subject,body)
If subject = "SharePoint Backup Process successfully completed" Then
objShell.LogEvent 0, body
Else
objShell.LogEvent 1, body
end If
End Sub
Sub deleteBackupFolder (backupLocation)
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FolderExists(backupLocation)) Then
' Delete existing backup folder
objFSO.DeleteFolder(backupLocation)
' Create new backup folder
objFSO.createFolder(backupLocation)
Else
' Folder not present therefore create new folder
objFSO.createFolder(backupLocation)
End If
End Sub
I'd love to say this is my handy work, but it isn't. I'm not sure where I've found it, but it sure is useful.
Cheers,
Matt