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 ?

1 ACCEPTED SOLUTION

Accepted Solutions

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

 

View solution in original post

34 REPLIES 34

revarooo
Level 6
Employee

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

 

Yes it mentions in that technote that you need to install and configure Blat for this purpose.

Following that technote should work fine.

sdo
Moderator
Moderator
Partner    VIP    Certified

You do not 'have to' use blat.  You could use any script or tool within mail_dr_info.cmd that can send emails.  The things that you must do, are:

1) Place your email logic inside a script named 'mail_dr_info.cmd' in the apporporiate folder.

2) The mail_dr_info.cmd script AND everything within it absolutely MUST run silently - i.e. absolutely no output generated to stdout or stderr - otherwise the component of NetBackup that calls 'mail_dr_info.cmd' gets confused and thinks that the call to mail_dr_info.cmd has failed in someway.

sdo
Moderator
Moderator
Partner    VIP    Certified

As a basic minimum you need to do this:

1) Where 'someone@whocares.com' is the target email address, and 'x.x.x.x' is the IP address of your SMTP gateway:

copy  "D:\Program Files\Veritas\NetBackup\bin\goodies\nbmail.cmd"  "D:\Program Files\Veritas\NetBackup\bin\mail_dr_info.cmd"

notepad "D:\Program Files\Veritas\NetBackup\bin\mail_dr_info.cmd"

...replace    -server WARTHOG        ...with        -server X.X.X.X
...replace    -i NetBackup        ...with        -i someone@whocares.com

...and uncomment the mid section of code, i.e. remove the REM, but keep the leading @, from these five lines of code:

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

@blat %3 -s %2 -t %1 -i someone@whocares.com -server x.x.x.x -q
@) ELSE (
@blat %3 -s %2 -t %1 -i someone@whocares.com -server x.x.x.x -q -attach %4
@)

...click save, to save your changes.

2) However, I prefer to use a script like this, so that I can have a log of the parameters that mail_dr_info.cmd actually receives from NetBackup AND a log of whether the email send actually worked or not, so maybe something like this:

@echo off
setlocal enabledelayedexpansion
 
 
REM **************************************************************************************
REM *  File:  mail_dr_info.cmd
REM *  Desc:  Called by NetBackup to email the status of the catalog backup...
REM *         ...and attach the DR file if the catalog backup is successful.
REM *
REM *  Vers   Date          Who    Description
REM *  ----   ----          ---    -----------
REM *  v0.1   20-MAY-2013   sdo    Original version.
REM *  v0.2   03-SEP-2013   sdo    P4 = "(null)" if there is no DR file.
REM **************************************************************************************
 
 
set z_path=%~dp0
set z_name=%~n0
 
set z_file_log=!z_path!!z_name!.log
 
set /a z_sts=0
 
 
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
 
 
echo+ >>"!z_file_log!"
echo P1 = %1 >>"!z_file_log!"
echo P2 = %2 >>"!z_file_log!"
echo P3 = %3 >>"!z_file_log!"
echo P4 = %4 >>"!z_file_log!"
 
 
if "%~4"=="(null)" (
  call :log "Emailing without attachment..."
  blat %3 -s %2 -t %1 -i someone@whocares.com -server x.x.x.x -q >>"!z_file_log!" 2>&1
  set z_sts=!errorlevel!
  call :log "...blat status `!z_sts!`..."
 
) else (
  call :log "Emailing with attachment..."
  blat %3 -s %2 -t %1 -i someone@whocares.com -server x.x.x.x -attach %4 -q >>"!z_file_log!" 2>&1
  set z_sts=!errorlevel!
  call :log "...blat status `!z_sts!`..."
)
 
:end
exit /b !z_sts!
 
 
 
 
:log
(echo !date! !time:~0,8!  %~1)>>"!z_file_log!"
goto :eof​

3) Here's a tip - at some point, and I'm sorry but I can't remember which version - NetBackup changed from sending P4 = ""   to sending P4 = "(null)"   (when there is no DR file to attach)    -    so, basically, you may have to change the statement in the script from:

if "%~4"=="(null)" (

...to:

if "%~4"=="" (

HTH.

V4
Level 6
Partner Accredited

What issues are you facing . Have you tried configuring it as mentioned in TN.

To allow NBU to send alerts to you, firstly you need to allow NBU server ip IN YOUR messaging environment (in case of exchange simply add it in receive connector with accept anonymous permissions)

 

Install and configure BLAT on NBU server specify SMTP server details and mention nbu server hostname/ip (details are given in TN)

 

Open 25 port if NBU server and SMTP has firewall in between by anychance.

sym_biosis
Level 4

I cannot use BLAT.exe thrid party tool in my environment.

I'm using -

System.Net.Mail.MailMessage to create mail message
System.Net.Mail.SmtpClient to send mail
 

I put everything in a  file.ps1

I'm invoking the PS with four parameters from the file mail_dr_info.cmd in /netbackup/bin

 

However look like the mail_dr_info.cmd actually is not getting invoked.
 

sdo
Moderator
Moderator
Partner    VIP    Certified
I must admit that I once tried using PS inside mail_dr_info.cmd - and I couldn't get it to work - what I found is that the DOS batch file "mail_dr_info.cmd" receives the three/four parameters with quotes around the strings - and I couldn't get (a DOS batch call to PS (within mail_dr_indo.cmd)) to accept parameters with what are effectively embedded surrounding quotes  PS strips the quotes off.  But then maybe my PS skills (non-existent) were not up to the task (100% likely).  If you do find a way - then I'm sure many many others would appreciate you sharing the know how.  Or can anyone else help the OP?

Here's my notes re testing PS:

Here's some examples of trying to figure the syntax for PS:
 
powershell send-mailmessage -from me@mine.com -to someone@whocares.com -Subject "test" -Body "some text" -Attachments version.txt -SmtpServer 1.1.1.1 -Credential me@mine.com
 
powershell send-mailmessage -from me@mine.com -to someone@whocares.com -Subject "test" -Body (get-content version.txt) -Attachments version.txt -SmtpServer 1.1.1.1
 
powershell send-mailmessage -from me@mine.com -to someone@whocares.com -Subject "test" -Body "$(get-content body.txt | out-string)" -Attachments version.txt -SmtpServer 1.1.1.1
 
...and I found that this worked from the CLI...
powershell send-mailmessage -from me@mine.com -to someone@whocares.com -Subject "test" -Body "$(get-content body.txt | out-string)" -Attachments version.txt -SmtpServer 1.1.1.1
 
...so I thought I'd try testing using this inside mail_dr_info.cmd...
powershell send-mailmessage -From me@mine.com -To %1 -Subject "%2" -Body "$(get-content %3 | out-string)" -Attachments %4 -SmtpServer 1.1.1.1
 
 
...so I tested by using...
Lines of code for      bin\mail_dr_info.cmd
 
     @IF "%~4"=="" (
     powershell send-mailmessage -from me@mine.com -to %1 -Subject "%2" -Body "$(get-content %3 | out-string)" -SmtpServer 1.1.1.1
     ) ELSE (
     powershell send-mailmessage -from me@mine.com -to %1 -Subject "%2" -Body "$(get-content %3 | out-string)" -Attachments %4 -SmtpServer 1.1.1.1
     )
 
...but I found that...
PowerShell cannot be used as the powershell command line strips out quotes and double-quotes and seeing as NetBackup sends all four parameters with quotes, and that the info (body text) file path ususually contains a space - then PS cannot be used.
 
...so - use the "blat" utility, or roll our own VBscripts.
 
...to test our SMTP server using our own script:
     (...FYI - CDO appears to require full file path/spec for attachments...)
 
cscript mail_dr_info.vbs "me@mine.com" "Test NetBackup Catalog from %computername%" "test-body.txt" "C:\Program Files\Veritas\NetBackup\bin\test-attachment.txt"
 
...and:
mail_dr_info.cmd         "me@mine.com" "Test NetBackup Catalog from %computername%" "test-body.txt" "C:\Program Files\Veritas\NetBackup\bin\test-attachment.txt"
 
I might have a VBScript that you could try playing with - if you also cannot get PS to work from within mail_dr_info.cmd - let me know if you want to see it.

sym_biosis
Level 4

I did below entry at the last in dr_file_info.cmd to check, it actually works. Looks like NB is not touching it.

Any suggestions ?

 

@REM - )
@REM -

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

echo %1 >> test.txt 2>> test2.txt
echo %2 >> test.txt 2>> test2.txt
echo %3 >> test.txt 2>> test2.txt
echo %4 >> test.txt 2>> test2.txt

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

sdo
Moderator
Moderator
Partner    VIP    Certified

Apologies, I don't understand the 'NB is not touching it' point?  Please re-explain?

Maybe your dr_file_info.cmd should be renamed to mail_dr_info.cmd ?

sym_biosis
Level 4

let me correct the post -

mail_dr_info.cmd - it is the file inside /netbackup/bin

I don't understand the 'NB is not touching it' point?  Please re-explain? - I meant NB is neither invoking it nor passing any parameter to it. I echoed the parameter to see what are the parameters getting passed to it.

 

 

 

sdo
Moderator
Moderator
Partner    VIP    Certified

Try these, so that there is at least something to echo (even if the parameters are empty) - i.e. echo does not like printing nothing, and actually causes output of "echo is on/off."

So maybe try:

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

How are you testing?  By actually running a catalog backup?

Remember the "mail_dr_info.cmd" is executed by the parent process which is probably running as NT_System_Authority - but 'where' is its 'default directory' while it is running?  Maybe the file "test.txt" is being created in some other folder and not where you expect it to be?

So maybe try:

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

 

sym_biosis
Level 4

Tried running by modifying mail_dr_info.cmd  -

 

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

 

Nothing is there inside E:\temp\

Looks like NB even not firing mail_dr_info.cmd 

sym_biosis
Level 4

Tried below by modifying mail_dr_info.cmd

 

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

 

Nothing came inside E:\temp.

 

May be mail_dr_info.cmd is not getting invoked by NB ? Any setting that I need to check ?

sym_biosis
Level 4

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

 

tried this - nothing came inside E:\temp

sdo
Moderator
Moderator
Partner    VIP    Certified

Are you running a catalog backup to test this?

Have you configured email properties in "Disaster Recovery" tab in the catalog backup policy?

sym_biosis
Level 4

Yes I'm running catalog backup to test this.

Yes I specified the email properties in the DR tab in the catalog backup policy.

sdo
Moderator
Moderator
Partner    VIP    Certified

What does the whole of your script:

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

...look like?  Can you post it as text?

sdo
Moderator
Moderator
Partner    VIP    Certified

Did you get this to work in the end?

If yes, what was your solution?

If no, can I help?

Marianne
Moderator
Moderator
Partner    VIP    Accredited Certified
Soooooo frustrating when users stop responding to attempts to help ....

sym_biosis
Level 4

My apologies for replying late. It is still not solved. I opened an official case with Symantec on this.

 

 

Here is the PS script -

 

Pardon me for writing this big. PS has Send-MailMessage command to do this :p  …… anyways here it goes. The commented out lines should not be commented out. I did that while doing some testing. I forgot why I did that.

 

param (

[string]$emlto,

[string]$sub,

[string]$msg,

[string]$attch

)

 

 

$smtp=new-object Net.Mail.SmtpClient("<mail-gateway>",25)

$emailFrom = new-object Net.Mail.MailAddress("email@address.com")

$emailTO   = new-object Net.Mail.MailAddress("email@address.com ")

$mlmsg     = new-object Net.Mail.MailMessage($emailFrom,$emailTO)

$mlmsg.Subject=$sub

$mlmsg.Body=$attch

#$data = new-object Net.Mail.Attachment("F:\Catalog\EURAZA-NBKP201_CATALOG_DR_FILE\$attch")

#$mlmsg.Attachments.Add($data)

$smtp.Send($mlmsg)