cancel
Showing results for 
Search instead for 
Did you mean: 

how to configure mail for Netbackup Windows

sym_biosis
Level 4

Going through the TN

http://www.symantec.com/business/support/index?page=content&id=TECH24110

Do I need to use third party tool to relay mails to the e-mail gateway ?

Is there any other way arounf for Windows ?

34 REPLIES 34

sym_biosis
Level 4

E:\Program Files\Veritas\NetBackup\bin\mail_dr_info.cmd

@REM $Header: nbmail.cmd,v 1.8 2005/05/10 16:12:29 $

 

@REM

 

@REM bcpyrght

 

@REM ***************************************************************************

 

@REM * $VRTScprght: Copyright 2014 Symantec Corporation, All Rights Reserved SY39-6648-5573-26-15-5  $ *

 

@REM ***************************************************************************

 

@REM ecpyrght

 

@REM

 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

@REM -                                                                         -

 

@REM - HOW TO SEND MAIL FROM THE NT NETBACKUP SERVER                           -

 

@REM -                                                                         -

 

@REM - NetBackup checks if the mail script (NetBackup\Bin\nbmail.cmd) exists.  -

 

@REM - If the script exists, NetBackup runs it passing four parameters on the  -

 

@REM - command line:                                                       -

 

@REM -                                                                         -

 

@REM -      %1 is the recipient's address                                      -

 

@REM -      %2 is the subject line                                             -

 

@REM -      %3 is the message file name                                        -

@REM -      %4 is the attached file name                                       -

 

@REM -                                                                         -

 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@REM -                                                                         -

 

@REM - HOW TO SEND DR MAIL FROM THE NT NETBACKUP SERVER                        -

 

@REM -                                                                         -

 

@REM - NetBackup DR protection checks if the mail script                       -

@REM - (NetBackup\Bin\mail_dr_info.cmd) exists.  If the script exists          -

 

@REM - NetBackup DR protection runs it passing four parameters on the          -

 

@REM - command line:                                                           -

 

@REM -                                                                         -

 

@REM -      %1 is the recipient's address                                      -

 

@REM -      %2 is the subject line                                             -

 

@REM -      %3 is the message file name                                        -

@REM -      %4 is the attached file name                                       -

 

@REM -                                                                         -

 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

@REM -                                                                         -

 

@REM - A public domain SMTP mail client for NT called BLAT is available at:    -

 

@REM -                                                                         -

 

@REM -                       http://blat.net/                                  -

 

@REM -                                                                         -

 

@REM - Here's how to use BLAT with the NetBackup NT server.                    -

 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

@REM

@REM @IF "%~4"=="" (

 

@REM blat %3 -s %2 -t %1 -i NetBackup -server WARTHOG -q

@REM ) ELSE (

@REM blat %3 -s %2 -t %1 -i NetBackup -server WARTHOG -q -attach %4

@REM )

 

@REM

 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

@REM - The -i option designates the originator's address, you may change this  -

 

@REM - or omit it altogether (the default is the sender's address specified    -

 

@REM - when BLAT was installed).                                               -

 

@REM -                                                                         -

 

@REM - The -server option is given as an example, you need to determine the    -

 

@REM - correct name of your SMTP server.  This option may also be omitted      -

 

@REM - (the default is the server specified when installing BLAT).             -

 

@REM -                                                                         -

 

@REM - You may use any mail program you want, as long as it has a command line -

 

@REM - interface that can be used to send mail.  Just substitute a call to     -

 

@REM - your favorite mail program for the call to BLAT above.                  -

 

@REM -                                                                         -

 

@REM - After modifying this script to suit your situation (make sure you are   -

 

@REM - calling a valid mail program and the call is not commented out),        -

 

@REM - activate it by moving it to the NetBackup\Bin directory.                -

 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

@REM - Some email servers do not handle the formating of the messages created  -

 

@REM - by NetBackup.  Here is an example of how to get Exchange or IIS to      -

 

@REM - send the mail messages.                                                                                                    -

 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@REM - @copy /y %3 %TEMP%\nbmail.tmp > NUL

@REM - @echo . >> %TEMP%\nbmail.tmp

@REM - @IF "%~4"=="" (

@REM - blat %TEMP%\nbmail.tmp -s %2 -t %1 -q

@REM - ) ELSE (

@REM - blat %TEMP%\nbmail.tmp -s %2 -t %1 -q -attach %4

@REM - )

@REM -

 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

echo P1 = %1 >>"E:\temp\test.txt" 2>&1

echo P2 = %2 >>"E:\temp\test.txt" 2>&1

echo P3 = %3 >>"E:\temp\test.txt" 2>&1

echo P4 = %4 >>"E:\temp\test.txt" 2>&1

 

@REM powershell.exe "E:\Program Files\Veritas\NetBackup\bin\mailer.ps1" %1 %2 %3 %4

 

sdo
Moderator
Moderator
Partner    VIP    Certified
Ok - It seems like to me that your method is no different to anything else that I have tried previously with PowerShell, and I couldn't get a PS based script to work either. Would you like a short VBScript to try? No promises that it will work for you, but I will test it in my lab, and at least prove that it works for me.

sym_biosis
Level 4

The problem is ...../netbackup/bin/mail_dr_info.cmd is not getting invoked after the catalog backup completes, therefore I cannot test the powershell part.

 

 

sdo
Moderator
Moderator
Partner    VIP    Certified

Any news?

sdo
Moderator
Moderator
Partner    VIP    Certified

1) Is the owner of the file wrong?

C:\Program Files\Veritas\NetBackup\bin>dir /q mail_dr_info.cmd
 Volume in drive C is Win2008
 Volume Serial Number is FCDE-077C

 Directory of C:\Program Files\Veritas\NetBackup\bin

06/04/2015  23:17               963 BUILTIN\Administrators mail_dr_info.
               1 File(s)            963 bytes
               0 Dir(s)  158,848,290,816 bytes free

2) Is there an ACL on the file, blocking the NT Local System Authority from accessing/reading/running the file/script?

C:\Program Files\Veritas\NetBackup\bin>cacls mail_dr_info.cmd
C:\Program Files\Veritas\NetBackup\bin\mail_dr_info.cmd
      NT AUTHORITY\SYSTEM:(ID)F
      BUILTIN\Administrators:(ID)F
      BUILTIN\Users:(ID)R​

3) Are any of the local NetBackup services on the master running as a different username?

4) I've noticed that your script does not have leading '@' on the echo statements.  What a leading '@' does is hide the command from being 'echo'ed.  So, because you do not have an '@echo off' at the very start (first line) of your script, this means that the four 'echo' statements that appear later, are being echo'ed to stdout, which confuses the NetBackup service/daemon which is calling mail_dr_info.cmd.  Remember that 'mail_dr_info.cmd' must run silently, with no output to stdout or to stderr.  So, I think you could/should temporarily replace your mail_dr_info.cmd with this below, and see if this produces any output:

@echo off
echo P1 = %1 >>"E:\temp\test.txt" 2>&1
echo P2 = %2 >>"E:\temp\test.txt" 2>&1
echo P3 = %3 >>"E:\temp\test.txt" 2>&1
echo P4 = %4 >>"E:\temp\test.txt" 2>&1
exit /b 0

HTH.

sym_biosis
Level 4

you are right, NB is invoking mail_dr_info.cmd, I tested with echo as you asked :)

manual run of mail_dr_info.cmd is working fine and invoking the ps script. However, when running through catalog backup I'm not getting any mail. Please cehck if I need to correct anything in the bold.

 

echo P1 = %1 >>"E:\temp\test.txt" 2>&1
echo P2 = %2 >>"E:\temp\test.txt" 2>&1
echo P3 = %3 >>"E:\temp\test.txt" 2>&1
echo P4 = %4 >>"E:\temp\test.txt" 2>&1

powershell -File .\mailer.ps1 %1 %2 %3 %4

sdo
Moderator
Moderator
Partner    VIP    Certified

Ok - I need to see:

1) The whole of the 'mail_dr_info.cmd' script.   ( I do not need to see the powershell script).

2) Also need to see the contents of E:\temp\test.txt  (I need to see the last four lines only - but I need to see all of the punctuation - feel free to amend the 'server' names if you want - but I need to see all other characters from the last four lines).

...and then I think I'll be able to give you some test commands which will prove whether the PowerShell script really is working or not.

sym_biosis
Level 4

Here is the content of mail_dr_infocmd -

@echo off
@REM $Header: nbmail.cmd,v 1.8 2005/05/10 16:12:29 $

@REM

@REM bcpyrght

@REM ***************************************************************************

@REM * $VRTScprght: Copyright 2014 Symantec Corporation, All Rights Reserved SY39-6648-5573-26-15-5  $ *

@REM ***************************************************************************

@REM ecpyrght

@REM 

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@REM -                                                                         -

@REM - HOW TO SEND MAIL FROM THE NT NETBACKUP SERVER                           -

@REM -                                                                         -

@REM - NetBackup checks if the mail script (NetBackup\Bin\nbmail.cmd) exists.  -

@REM - If the script exists, NetBackup runs it passing four parameters on the  -

@REM - command line:                                                       -

@REM -                                                                         -

@REM -      %1 is the recipient's address                                      -

@REM -      %2 is the subject line                                             -

@REM -      %3 is the message file name                                        -
@REM -      %4 is the attached file name                                       -

@REM -                                                                         -

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@REM -                                                                         -

@REM - HOW TO SEND DR MAIL FROM THE NT NETBACKUP SERVER                        -

@REM -                                                                         -

@REM - NetBackup DR protection checks if the mail script                       -
@REM - (NetBackup\Bin\mail_dr_info.cmd) exists.  If the script exists          -

@REM - NetBackup DR protection runs it passing four parameters on the          -

@REM - command line:                                                           -

@REM -                                                                         -

@REM -      %1 is the recipient's address                                      -

@REM -      %2 is the subject line                                             -

@REM -      %3 is the message file name                                        -
@REM -      %4 is the attached file name                                       -

@REM -                                                                         -

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@REM -                                                                         -

@REM - A public domain SMTP mail client for NT called BLAT is available at:    -

@REM -                                                                         -

@REM -                       http://blat.net/                                  -

@REM -                                                                         -

@REM - Here's how to use BLAT with the NetBackup NT server.                    -

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@REM
@REM @IF "%~4"=="" (

@REM blat %3 -s %2 -t %1 -i NetBackup -server WARTHOG -q
@REM ) ELSE (
@REM blat %3 -s %2 -t %1 -i NetBackup -server WARTHOG -q -attach %4
@REM )

@REM

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@REM - The -i option designates the originator's address, you may change this  -

@REM - or omit it altogether (the default is the sender's address specified    -

@REM - when BLAT was installed).                                               -

@REM -                                                                         -

@REM - The -server option is given as an example, you need to determine the    -

@REM - correct name of your SMTP server.  This option may also be omitted      -

@REM - (the default is the server specified when installing BLAT).             -

@REM -                                                                         -

@REM - You may use any mail program you want, as long as it has a command line -

@REM - interface that can be used to send mail.  Just substitute a call to     -

@REM - your favorite mail program for the call to BLAT above.                  -

@REM -                                                                         -

@REM - After modifying this script to suit your situation (make sure you are   -

@REM - calling a valid mail program and the call is not commented out),        -

@REM - activate it by moving it to the NetBackup\Bin directory.                -

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@REM - Some email servers do not handle the formating of the messages created  -

@REM - by NetBackup.  Here is an example of how to get Exchange or IIS to      -

@REM - send the mail messages.                               -

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@REM - @copy /y %3 %TEMP%\nbmail.tmp > NUL
@REM - @echo . >> %TEMP%\nbmail.tmp
@REM - @IF "%~4"=="" (
@REM - blat %TEMP%\nbmail.tmp -s %2 -t %1 -q
@REM - ) ELSE (
@REM - blat %TEMP%\nbmail.tmp -s %2 -t %1 -q -attach %4
@REM - )
@REM -

@REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

echo P1 = %1 >>"E:\temp\test.txt" 2>&1
echo P2 = %2 >>"E:\temp\test.txt" 2>&1
echo P3 = %3 >>"E:\temp\test.txt" 2>&1
echo P4 = %4 >>"E:\temp\test.txt" 2>&1

powershell -File .\mailer.ps1 %1 %2 %3 %4

sym_biosis
Level 4

Here is the content of test.txt -

 

P1 = "<recipient_list>" 
P2 = "NetBackup Catalog Backup successful on host XXXXXXXXX.com status 0" 
P3 = "E:\Program Files\Veritas\NetBackup\db\mail\XXXXXXXXX.com_1428925071" 
P4 = "F:\Catalog\XXXXXXXXX_CATALOG_DR_FILE\Hot-Catalog_1428925071_FULL" 

sdo
Moderator
Moderator
Partner    VIP    Certified

Ok - thanks for that.

Can you see how the parameters received by mail_dr_info.cmd are all surrounded by quotes?  i.e. the content of the parameters actually contain quotes !

And the reason for this is that the subject header (P2), and the mail body text (P3) both can (and do in this case) contain spaces, and so must be pre-encapsulated within quotes.

The problem I had when trying to get a PowerShell script to work was... that, in my tests, PS would strip off the quotes when it ingested the parameters - and so PS thought that is was receiving what effectively amounted to about 13 or so  parameters.  Like I said before, I couldn't get PS to work, but maybe you can.  If you do, I'd like to know how.  :)

.

In the meantime, I think you could try re-testing your PS script outside of mail_dr_info.cmd, by:

1) Create a test folder named:     C:\Mail Test\       (you need the space in the path name for an accurate test)

2) In that folder create two files...

3) body.txt        and put multiple lines of junk in it, with some white space in the text, and some interspersed empty lines, and some punctuation characters, and a trailing line of:  END

4) attachment.txt     again, multiple lines of gibberish, with white space and white lines and puctuation characters, and a trailing line of:   END

5) Test your call to your PS script with:

> powershell -file .\mailer.ps1 "me@myfirm.com" "Subject test with spacing..." "C:\Mail Test\body.txt" "C:\Mail Test\attachment.txt"

.

Do you recieve an email?

Or does PS groan?

Did the email contain all lines in both the email body and the attachment up to and including the END moniker?

sdo
Moderator
Moderator
Partner    VIP    Certified

If you are able to share the mailer.ps1 script with me (but edit out any site specifics), then I might be able to test with an idea that I have - otherwise, you might have to try using VBscript, or perl, or python?

sdo
Moderator
Moderator
Partner    VIP    Certified

Need an example VBscript to send SMTP emails?

...but it might not work for you... as the script that I have makes references to some 'http' objects from Microsoft... but these may be intercepted by the SMTP dll based objects that VBscript calls - and so it may turn out that your master does not need internet access to be able to reference the http objects used by the VBscript calls to SMTP objects.

sdo
Moderator
Moderator
Partner    VIP    Certified

Any news?

These links may help you re 'escaping' "quotes"   :\     in powershell:

http://stackoverflow.com/questions/6714165/powershell-stripping-double-quotes-from-command-line-arguments

https://connect.microsoft.com/PowerShell/feedback/details/376207/executing-commands-which-require-quotes-and-variables-is-practically-impossible

 

 

sdo
Moderator
Moderator
Partner    VIP    Certified

Hi sym_biosis - any news?  Did you get PS to work?

sdo
Moderator
Moderator
Partner    VIP    Certified

Any news?

BTW - another forum member has kindly posted an example of a VBscript to send emails via SMTP call to a Microsoft object.  The posted example does not do attachments, but I'm sure that you could work that bit out.

https://www-secure.symantec.com/connect/forums/email-notifications-without-blat