cancel
Showing results for 
Search instead for 
Did you mean: 
kumar3
Level 4
Certified

Description: This script will monitor backup jobs and send a mail to Backup Admin or some who cares if the job is running. Put the entry in the cron and this will send mail as per given interval in cron job.

Cron job example:

0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /usr/openv/netbackup/bin/BackupStatus.sh > /dev/null 2>&1

 

#!/bin/bash
 
echo "Client,     Policy Name,    Running Since" > /tmp/final;
 
# Get Job ID
/usr/openv/netbackup/bin/admincmd/bpdbjobs -report -noheader | grep Active | awk '{print $1}' > /tmp/jobstemp ;
 
# Loop through each Job ID
for job in `cat /tmp/jobstemp`
do
        # Get Client Name
        a=`/usr/openv/netbackup/bin/admincmd/bpdbjobs -all_columns -jobid $job | awk -F, '{print $7}'`;
        # Check if Client Name is critical Client
        if [ $a = 'clientA' ] || [ $a = 'clientB' ] || [ $a = 'clientC' ] || [ $a = 'clientD' ]; then
                # Criticl Client, get Client Name, Policy Name and Backup Job Start Time
                 /usr/openv/netbackup/bin/admincmd/bpdbjobs -all_columns -jobid $job | awk -F, '{print $7", "$5", "substr($45,0,17)}' >> /tmp/final;
        fi
done
 
# Sent mail to person who cares
size=`more /tmp/final | wc -l`;
if [ $size -ne 1 ]
then
        cat /tmp/final | mailx -s "Critical Backup Running Since" 'abc@xyz.com' 'abc@xyz.com';
fi

Comments
Vickie
Level 6

Thanks for the script.

I have tried this script but getting error, where the client is not matching the critical client name.

If gives error like below,

./client.sh: line 14: [: =: unary operator expected
./client.sh: line 14: [: =: unary operator expected
./client.sh: line 14: [: =: unary operator expected
./client.sh: line 14: [: =: unary operator expected

./client.sh: line 14: [: =: unary operator expected
./client.sh: line 14: [: =: unary operator expected

Plz assist get this error removed.

Version history
Last update:
‎10-19-2010 09:48 PM
Updated by: