Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS backup and email notification ?

Status
Not open for further replies.

pjwraith

Technical User
May 17, 2002
12
GB
I know that there is no option to include email notification of success/failure with MS backup, however I have a zero budget and would like to implement this !

Are there any plugins/free alternatives available to anyones knowledge?

Thanks for your time.
 
Yes, I do this with vbscript that I schedule to run each morning. Will be happy to post it for you when I am in the office tomorrow.

I hope you find this post helpful.

Regards,

Mark
 
Thanks for the help, I will play with Blat today and look forward to the vbscript Mark. :)

You just know this backup is going to fail the one week I am on holiday and no-one checks......
 
Sorry for the delay in posting this. Been crazy at work lately.

Code:
'*************************************************** 
'Search for failed backup in log file 
'By Mark D. MacLachlan
                                                         

'Creation date: 02/17/2003
'Modifications: 06/04/2003 Added support to look for job not run due to no media 
'               03/17/2004 Moved variables needing change to top of script for easy editing  
'               4/28/2005  Removed RegExpressions testing.  Testing now uses Instr to get status.  
'                          Modified date detection as datediff was returning negative numbers.
'*************************************************** 

On Error Resume Next 

'Declare our variables 
Dim Status, oFSO, objShell, logFile , myToday, date_modified, daysbetween
Dim oName, ODomain, oMyIP, oTo 
Const ForReading = 1


' Set the company specific information 
'Log file location
folder_path = "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data"
' Company Internet Domain Name 
ODomain = "company.com" 
' Set the SMTP server IP 
oMyIP = "192.168.1.92" 
' Where do you want the message to be delivered 
oTo = "support@company.com" 


 
  
myToday = FormatDateTime(Now(), vbShortDate)

'open the file system object 
Set oFSO = CreateObject("Scripting.FileSystemObject") 
set objShell = CreateObject("wscript.shell") 

'open the data file

set fld = oFSO.getfolder(folder_path)

set fldContents=fld.files 

For each f in fldContents 
      If right(f.name,3)="log" Then
	   date_modified=FormatDateTime(f.DateLastModified, vbShortDate)
	   daysbetween= DateDiff("d",myToday,date_modified)
	
		  If daysbetween <0 And daysbetween >(-2) then 
	             get_backup_log_file = f.name
	      Else 
	          	 get_backup_log_file = "No file"
	      End if 
       End if 
Next
 
logFile = get_backup_log_file
'MsgBox logFile
'wscript.quit

'if no data file then backup did not run 
If logFile="No file" Then 
        Status ="backup did not run"
        oTextStream ="No backup file to include"
	SendMail Status,oTextStream        
Else 

oTextStream = oFSO.OpenTextFile(folder_path & "\" & logFile, ForReading, False, -1).ReadAll 

'MsgBox "Contents of array will be" & vbCrLf & oTextStream 
myArray=Split(oTextStream,vbCrLf, -1, 1) 
Status = "Backup Believed To Have Succeeded"

	'Check if backup ran but failed
    For Each entry In myArray 
	'msgBox entry
	If Instr(1,entry,"did not successfully complete") Then
	    Status = "Backup Failed"
	ElseIf Instr(1,entry,"operation was not performed") Then
	    Status = "Backup Did Not Run"
	End If
    Next	
         'msgBox Status
	

End If

SendMail Status,oTextStream

Function SendMail(backupText,oTextStream)

'now send the message about the status 
' Get the computer name 
Set WshNetwork = CreateObject("WScript.Network") 
oName = WshNetwork.ComputerName 


' Set the visual basic constants as they do not exist within VBScript. 
' Do not set your smtp server information here. 
Const cdoSendUsingMethod = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing",[/URL] _ 
cdoSendUsingPort = 2, _ 
cdoSMTPServer = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver"[/URL] 

'Create the CDO connections. 
Dim iMsg, iConf, Flds 
Set iMsg = CreateObject("CDO.Message") 
Set iConf = CreateObject("CDO.Configuration") 
Set Flds = iConf.Fields 

'SMTP server configuration. 
With Flds 
.Item(cdoSendUsingMethod) = cdoSendUsingPort 

'Set the SMTP server address here. 
.Item(cdoSMTPServer) = oMyIP 
.Update 
End With 

'Set the message properties. 
With iMsg 
Set .Configuration = iConf 
.To = oTo 
.From = oName & "@" & oDomain 
.Subject = oName & " "& Status
.TextBody = "Server " & oName & " at company " & ODomain & " " & Status & " " & Now & vbCrLf & oTextStream 
End With 

Wscript.Echo iMsg.TextBody

'An attachment can be included. 
'iMsg.AddAttachment logfile 

'Send the message. 
iMsg.Send 
WScript.Quit 
End Function

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top