Enumerating the If... Then: Scripts

Tuesday, April 29, 2008

Symantec: Send an Email alert when Backup Exec System Recovery backup job fails

Tested.
In use at work.


Set this script to activate after your backup job completes.


Set objShell = CreateObject("WScript.Shell")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile_
("c:\documents and settings\all users\application data\symantec\backup exec system recovery\logs\backup exec system recovery.log.txt", 1, 0, -2)


strSearchString = "High Priority"


i = 0

do while not objFile.atendofstream
redim preserve strLines(i)
strLines(i) = objFile.readline
i = i + 1
loop

objFile.close

strLastLine = strLines(i-1)


if instr(strLastLine,strSearchString) <> 0 then

strEmailBody = mid(strLastLine, instr(strLastLine,strSearchString),_
len(strLastLine) - instr(strLastLine,strSearchString) + 1)


'''' Sends Email
Set objMessage = CreateObject("CDO.Message")

objMessage.Subject = "[ " &

objShell.ExpandEnvironmentStrings("%COMPUTERNAME%") & " ] reporting a System

Recovery job error"
objMessage.From = "ImaFromAddr"
objMessage.To = "ImaToAddr"
objMessage.TextBody = strEmailBody

objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ImaSMTPSrv"
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update

objMessage.Send

else

' didn't find strSearchString in the last line of the file
wscript.echo "no string in string"

end if

0 Comments:

Post a Comment

<< Home