Forum Discussion

kkhoo's avatar
kkhoo
Level 5
9 years ago

how to use backup_exit_notify

hi gurus,

i have input conditions in backup_exit_notify.

i run some backup that will fail.

but am not getting any email notification.

please advise.

 

  • Here is my email distribution listing: (sorry winders people )

    ## I exclude notification on some error codes ($5), and I name ALL my Oracle child schedules, Child.Job, so I only get emails from the Parent.($3)

    if [ $5 != 0 -a $5 != 1 -a $5 != 71 -a $5 != 150 -a $5 != 800 -a $5 != 191 -a $3 != "Child.Job" ]
    then
            if /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep MS-Window
            then
                    cat $OUTF | /usr/bin/mailx -s "WINDOWS NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com windows@company.com
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep MS-Exchange
            then
                    cat $OUTF | /usr/bin/mailx -s "EXCHANGE NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com windows@company.com
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep VMWARE
            then
                    cat $OUTF | /usr/bin/mailx -s "VMWARE NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com windows@companys.com
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep MS-SQL
            then
                    cat $OUTF | /usr/bin/mailx -s "MS-SQL NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com windows@company.com dba@company.com
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep Oracle
            then
                    cat $OUTF | /usr/bin/mailx -s "ORACLE NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com dba@company.com unix@company.com 
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep Sybase
            then
                    cat $OUTF | /usr/bin/mailx -s "SYBASE NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com dba@company.com unix@company.com 
            else
                    cat $OUTF | /usr/bin/mailx -s "UNIX NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com unix@company.com 
            fi
    fi

  • Please show us your script?

    Have you added a command to actually send the email?

  • hi sdo,

    yes. i think the problem is my script/ condition.

    echo ${dateStr} "-----------------------------" >> $OUTF
    echo ${dateStr} "       CLIENT:  $1" >> $OUTF
    echo ${dateStr} "       POLICY:  $2" >> $OUTF
    echo ${dateStr} "     SCHEDULE:  $3" >> $OUTF
    echo ${dateStr} "SCHEDULE TYPE:  $4" >> $OUTF
    echo ${dateStr} "       STATUS:  $5" >> $OUTF
    echo ${dateStr} "       STREAM:  $6" >> $OUTF
    echo ${dateStr} "-----------------------------" >> $OUTF

    NBUDIR="/usr/openv/netbackup/"
    LOGDIR="/usr/openv/netbackup/logs/"

    mailtodb='myemailadd'

    # ----------------------------------------------

    # exit not equal 0
    # ----------------------------------------------
    if [ "$5" -gt 1  &&  "$3" -eq db ]
    then
            echo "${1} $0 ${dateStr} $*" | mailx -s "WARNING FROM `hostname -s` ${1} $0 ${dateStr} $*" -r "`hostname -s`" ${mailtodb}
    fi

     

     

    please advise...

  • Is 'mailx' on your backup server working?

    Can you use mailx on cmd to send a test email?

    Is the $OUTF created?

  • What version are you on? Current versions have 8 ( EIGHT ) inputs, I just upgraded and what I ended updoing was essentially running the script manually, like :(path to binary)/backup_exit_notify 1 2 3 4 5 6 7 8 

    It should run cleanly. If not you should see the error right away.

     

    They did not change any of the existing inputs, they just added additional ones.

    From the script I have:

    # This script:
    #       receives 8 parameters:
    #         CLIENT           - the client hostname
    #         POLICY           - the policy label
    #         SCHEDULE         - the schedule label
    #         SCHEDULE_TYPE    - the type of schedule:  FULL INCR UBAK UARC
    #         STATUS           - the backup status for this job
    #         STREAM           - the backup stream number for this job
    #         DONE_TRYING      - 0=will retry, 1=done, will not retry.
    #         PRIMARY_JOBID    - the jobid for this job
    #       must be executable by the root user
    #       should exit with 0 upon successful completion
     

  • thanks Marianne and Genericus,

    Email is coming now.

    However, we wanted to filter out the "Policy Type".

    If it is standard backup... should trigger mail to sysadmins

    If it is oracle... trigger mail to dba

    Can this be done?

  • Set an if condition on $4 (Policy type) to then email the correct people.

     

  • I think you need to use the policy name.

    Something like:

    bppllist $2 | awk for field that is the policy type... and use an if to decide what to do based upon the policy type.

  • Here is my email distribution listing: (sorry winders people )

    ## I exclude notification on some error codes ($5), and I name ALL my Oracle child schedules, Child.Job, so I only get emails from the Parent.($3)

    if [ $5 != 0 -a $5 != 1 -a $5 != 71 -a $5 != 150 -a $5 != 800 -a $5 != 191 -a $3 != "Child.Job" ]
    then
            if /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep MS-Window
            then
                    cat $OUTF | /usr/bin/mailx -s "WINDOWS NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com windows@company.com
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep MS-Exchange
            then
                    cat $OUTF | /usr/bin/mailx -s "EXCHANGE NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com windows@company.com
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep VMWARE
            then
                    cat $OUTF | /usr/bin/mailx -s "VMWARE NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com windows@companys.com
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep MS-SQL
            then
                    cat $OUTF | /usr/bin/mailx -s "MS-SQL NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com windows@company.com dba@company.com
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep Oracle
            then
                    cat $OUTF | /usr/bin/mailx -s "ORACLE NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com dba@company.com unix@company.com 
            elif /usr/openv/netbackup/bin/admincmd/bppllist $2 -U | grep "Policy Type" | grep Sybase
            then
                    cat $OUTF | /usr/bin/mailx -s "SYBASE NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com dba@company.com unix@company.com 
            else
                    cat $OUTF | /usr/bin/mailx -s "UNIX NetBackup Error Status $5, Policy $2, Client $1" \
                    operations@company.com unix@company.com 
            fi
    fi