Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Script to check if backup for critical client running or not

Created: 19 Oct 2010 • Updated: 28 Oct 2010 | 1 comment
VKumar's picture
+2 2 Votes
Login to vote

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

Download Filed Under:

Comments 1 CommentJump to latest comment

Vickie's picture

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.

0
Login to vote