Email NTBackup log files

January 17th, 2008

Something I’ve needed to do recently in the day job is to email the log file of NTBackup to a designated person for checking daily. A scheduled tape backup runs every night at midnight and the resulting log file needs to be sent to the business IT helpdesk to check that the backup completed successfully.

Having searched around the web for a bit I couldn’t find anything that did exactly what I wanted as one vbscript and not multiple batch files, or just pseudo code. So I’ve written my own; the code is below and can be freely used as long as the acknowledgement remains.

Some bits need customising, such as the to and from address for the email, the location of the log files and the SMTP server address, but it should be obvious where to make the changes.

The script emails the log file which has the same ‘last modified’ date as the current date, so needs to be run the same day as the backup log is created (i.e. not 7am after an 11pm backup the day before). That can probably be tweaked however. If no file is found with the same date, no email is sent. Again this could be tweaked to send an email saying so.

You’ll need to schedule this script to run after the backup is known to have completed (or failed). Say 7am for a midnight backup schedule. Any queries, feel free to contact me and I’ll do my best to answer.

Get the script here. Save as a .vbs file and run using ‘cscript emailbackuplog.vbs’.

To specify a user name and password for SMTP authentication, add the following with the other oCDO.Configuration.Fields.Item entries.

oCDO.Configuration.Fields.Item _
		("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = _
			1
 
	oCDO.Configuration.Fields.Item _
		("http://schemas.microsoft.com/cdo/configuration/sendusername") = _
			"username"
 
	oCDO.Configuration.Fields.Item _
		("http://schemas.microsoft.com/cdo/configuration/sendpassword") = _
			"password"

Comments and modifications welcome.

2 Responses to “Email NTBackup log files”

  1. 1 ataylor
    January 22nd, 2008 at 4:20 pm

    A few updates and corrections made, thanks to VJ @ IT Quality.

  2. [...] this I use Andrew Taylor’s “Email NT Backup log file” script. Then my script has the additional line [...]