Forum Discussion
This is the way I have set the script set up to work, Please follow the instructions below.
Locate the nbmail.cmd file (%InstallDir%\Veritas\Netbackup\bin). You will need to add the following line email-PolicyStatus.vbs, to the section below and comment out the blat %TEMP%\nbmail.tmp -s %2 -t %1 -q line from nbmail.cmd. if you do not comment out the other line about the email-PolicyStatus.vbs you will receive two emails for each confirmation.
@copy /y %3 %TEMP%\nbmail.tmp > NUL
@IF "%~4"=="" (
::blat %TEMP%\nbmail.tmp -s %2 -t %1 -q
email-PolicyStatus.vbs
) ELSE (
blat %TEMP%\nbmail.tmp -s %2 -t %1 -q -attach %4
)
Copy and paste the code below into notepad and save it as a .vbs file. The file needs to be saved in the same location as the nbmail.cmd file. This directory is generally in the Veritas\Netbackup\bin folder.
You should then receive emails with the policy name in the subject line, as long as that policy was setup to have the server or client send the emails.
' *** CODE ***
' ***********************************************************
' **** Author: Chad Freiling ****
' **** Date: Dec. 5, 2008 ****
' **** ****
' **** Description: ****
' **** Finds a String in a Line read from a text file ****
' **** stores the policy name then emails the ****
' **** information to an email set in this file. ****
' **** ****
' **** This file must be in the following location ****
' **** %InstallPath%\VERITAS\NetBackup\bin ****
' **** Otherwise it will not work correctly. ****
' **** ****
' ***********************************************************
Dim x, strClient, strPolicy, strSize, strFile, strString ,strSearchString, strMatch
Dim BlatCMD, blatFile ' Path and File name that is sent out from netbackup server, generally it is nbmail.tmp
Const ForReading = 1
Const ForWriting = 2
' String to look for, this is not case sensitive, it will be converted to Upper Case
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "POLICY:" ' Change between the " " for string
' Path and Filename to search through
strFile = "BACKUP_EXIT_CALLED"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFile, ForReading)
Set objws = CreateObject("WScript.Shell")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
' tmp file that will be sent with the email, this file is created by NBU
' this file is generally found in C:\Windows\Temp\
blatFile = "C:\Windows\Temp\nbmail.tmp"
' Start to read through the file
Do Until objFile.AtEndOfStream
strSearchString = ucase(objFile.ReadLine)
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count > 0 Then
For Each strMatch in colMatches
' Remove all information but the policy name
strResult = trim(Replace(right(strSearchString, len(strSearchString) - instr(strSearchString, strMatch) + 1), strMatch, ""))
strResult = """Backup job completed for Policy " & strResult & """"
' *** Configuration for Blat to email information ***
' blatFile should be set to the tmp file that is normally sent
BlatCMD = "blat " & blatFile & " -to {removed email address} -s " & strResult
' Run Blat
objws.run BlatCMD
Next
End If
Loop
' *** END CODE ***
Hope this helps.
Related Content
- 10 months ago
- 6 months ago
- 11 years ago
- 3 years ago
- 11 years ago