Netbackup – Parent_end_notify.cmd

Scenario: You are using Netbackup and you are wanting a script to run when a job completes.

Options: There are two options, you can run a script on the client each time a child job runs and completes or you can run a script from the master server each time a parent completes.

I will focus on the Master Server.

Solution: Under %ProgramFiles%\Veritas\NetBackup\bin you will find a file called parent_end_notify.cmd. This is what you will use to run any script you need.

This is a .cmd, so be familiar with windows batch files. ūüėČ

There are seven parameters Netbackup sends to this batch file everytime a parent job completes.

@REM %1 = CLIENT – the client hostname
@REM %2 = POLICY – the policy label
@REM %3 = SCHEDULE – the schedule label
@REM %4 = SCHEDULE_TYPE – the type of schedule: FULL INCR UBAK
@REM UARC
@REM %5 = STATUS – the backup status for this job
@REM %6 = STREAM – the backup stream number for this job always -1
@REM %7 = STREAM_CNT – # streams started (if -1, genjob failed to call pem)

It is up to us to make the decision. In my case, I wanted to evaluate for three policies and if they completed with exit status 0 (successful), run a command.

Highlighted below are the bits I added in bold, I added this at the end of the script between the commented out mail section and EndMain

@REM – might want to mail this info to someone
@REM –
@REM – @call %NB_MAIL_SCRIPT% someone_who_cares “NetBackup parent end notify” %OUTF%
@REM —————————————————————————
@if “%2” == “Policy1” goto Policy1
@if “%2” == “Policy2”¬†goto¬†Policy2
@if “%2” == “Policy3” goto Policy3
goto EndMain
@REM —————————————————————————
:Policy1
@if “%5” == “0” goto Successful
@if “%5” != “0” goto NotSuccessful
:Successful
@ECHO “MyContent” > PathToFile.txt
goto EndMain
:NotSuccessful
goto EndMain
@REM —————————————————————————
:Policy2
@if “%5” == “0” goto Successful
@if “%5” != “0” goto NotSuccessful
:Successful
@ECHO “MyContent” > PathToFile.txt
goto EndMain
:NotSuccessful
goto EndMain
@REM —————————————————————————
:Policy3
@if “%5” == “0” goto Successful
@if “%5” != “0” goto¬†NotSuccessful
:Successful
@ECHO “MyContent” > PathToFile.txt
goto EndMain
:NotSuccessful
goto EndMain
@REM —————————————————————————
:EndMain
@endlocal
@REM – End of Main Program —————————————————–

Other Information: 

Master Server:

parent_start_notify
https://www.veritas.com/support/en_US/article.000044303

parent_end_notify https://www.veritas.com/support/en_US/article.HOWTO106055

Client Side: 

bpstart_notify
https://www.veritas.com/support/en_US/article.000044292

bpend_notify
https://www.veritas.com/support/en_US/article.000044293

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s