Veritas-bu

[Veritas-bu] Chart of backups

2001-10-23 17:04:52
Subject: [Veritas-bu] Chart of backups
From: veritas AT ratgut DOT com (Peter DrakeUnderkoffler)
Date: Tue, 23 Oct 2001 17:04:52 -0400
This is a multi-part message in MIME format.
--------------7BBBD312628E8FC7B9C939DB
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

John_Kennedy wrote:
> 
> We have over 100 classes on our NBU machines.  Is there a utility that
> will print out or display a chart of the times for each class backup?
> Thanks,
> John
> 
> --
> "I fear all we have done is to awaken the sleeping giant and fill
> him with terrible resolve"
> - Japanese Adm. Isoroku Yamamoto after the attack on Pearl Harbor
> _______________________________________________
> Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
> http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu

I haven't found one.  So I wrote something that runs in a cron once
a week to print out all the schedules sorted by time and categorized
by schedule names and active/inactive.  You may have to modify it a bit,
but you might find that this helps.  I'm sure most everyone out there
could re-write this much better, but it does the job for now.

Thanks
Peter
--------------7BBBD312628E8FC7B9C939DB
Content-Type: application/x-sh;
 name="nbuclass_sched.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="nbuclass_sched.sh"

#!/bin/sh
#
# $Id: nbuclass_sched.sh,v 1.3 2001/10/22 14:00:02 root Exp $
#

# Script to run every so often to e-mail out the current schedule
# and state of all configured classes

# Make sure we have email address past to us
if [ $# -lt 1 ] ; then
        printf "no email address specified\n"
        printf "usage: $0 email_address\n\n"
        exit 1
fi

# Now make sure we are running this on a NetBackup master
if [ -r /opt/openv/netbackup/bin/admincmd/bplicense ] ; then
        /opt/openv/netbackup/bin/admincmd/bplicense
        if [ $? -ne 0 ] ; then
                printf "NetBackup is not setup properly on this systems\n"
                printf " not running and exiting\n"
                exit 1
        fi
else
        printf "This is not a NetBackup master system\n"
        exit 1
fi

# Variables
OUTDIR=/var/tmp/nbusched_`date "+%m%d%Y%S"`
INACTIVE=${OUTDIR}/inactive
ACTIVE=${OUTDIR}/active
OUTFILE=${OUTDIR}/mailout
EMAIL_ADDR=$1
HERE=`pwd`
bpcllist=/opt/openv/netbackup/bin/admincmd/bpcllist
bpclsched=/opt/openv/netbackup/bin/admincmd/bpclsched


###
# Routine to cleanup

clean_up () {
        echo "removing temp dir"
        rm -rf ${OUTDIR}

}

###
# Routine to check for inactive classes
inactive_class () {
        printf "### The following classes are inactive ###\n\n" >> $OUTFILE
        cd /usr/openv/netbackup/db/class
        grep 'ACTIVE 1' */info | awk -F/ '{print $1}' >> $INACTIVE
        cat $INACTIVE >> $OUTFILE
        printf "\nNOTE:\n\tYou may want to check and make sure you don't want 
to activate them\n" >> $OUTFILE
}

###
# Routine to create the data
printout_schedule () {
        for class in `${bpcllist}` ; do
                ${bpclsched} $class -U -label Full | sed '/^$/d' > 
${OUTDIR}/${class}.Full
                ${bpclsched} $class -U -label Differential-Inc | sed '/^$/d' > 
${OUTDIR}/${class}.Inc
        done    

}

###
# Routine to create the tables and sort them
create_schedlist () {
        LIST=$1
        SCHEDTYPE=$2

        for class in `cat ${LIST}` ; do
                eval cat ${class}.${SCHEDTYPE} \
                | egrep 
'Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday' \
                | sed 's/ \{8\}/'"$class"' /' \
                | sed -e 's/Sunday/0_Sunday/' \
                -e 's/Monday/1_Monday/' \
                -e 's/Tuesday/2_Tuesday/' \
                -e 's/Wednesday/3_Wednesday/' \
                -e 's/Thursday/4_Thursday/' \
                -e 's/Friday/5_Friday/' \
                -e 's/Saturday/6_Saturday/'
        done

}

sort_output () {
        LIST=$1
        SCHEDTYPE=$2
        
        cat ${OUTDIR}/tmp | sort -k 2.1,3 \
        | sed 's/[0123456]_//g' \
        | awk '{printf "%-20s %+10s %s  %s  %9s  %-s\n", $1, $2, $3, $4, $5, 
$6}'
}


### The actual Program ##

# Make the directory
mkdir $OUTDIR
cat /dev/null > ${ACTIVE}
cat /dev/null > ${INACTIVE}
cat /dev/null > ${OUTFILE}

printf "#### Veritas NetBackup Schedule info for Brodeur WorldWide ###\n\n" >> 
$OUTFILE
# Call the routine to check inactivity
inactive_class

# Create the active list
for item in `cat ${INACTIVE}` ; do
TEMP="${item},"
done
TEMP=`echo $TEMP |sed -e 's/^,//' -e 's/,$//' -e 's/,/|/g'`
${bpcllist} | eval egrep -v '"$TEMP"' > ${ACTIVE}


# Call routine to print all the schedules
printout_schedule

cd ${OUTDIR}

# Call routine to print full schedule of class
#cat /dev/null > ${OUTDIR}/tmp
create_schedlist ${ACTIVE} Full > ${OUTDIR}/tmp
sort_output ${ACTIVE} Full > ${ACTIVE}.Full

# Call routine to print incemental schedule of class
#cat /dev/null > ${OUTDIR}/tmp
create_schedlist ${ACTIVE} Inc > ${OUTDIR}/tmp
sort_output ${ACTIVE} Inc > ${ACTIVE}.Inc

# Call routine to print full schedule of inactive classes
#cat /dev/null > ${OUTDIR}/tmp
create_schedlist ${INACTIVE} Full > ${OUTDIR}/tmp
sort_output ${INACTIVE} Full > ${INACTIVE}.Full

# Call routine to print incemental schedule of inactive classes
#cat /dev/null > ${OUTDIR}/tmp
create_schedlist ${INACTIVE} Inc > ${OUTDIR}/tmp
sort_output ${INACTIVE} Inc > ${INACTIVE}.Inc


cat << EOF >> $OUTFILE

#################################################
############### Schedules #######################

        - - -  Active Full - - -

`cat ${ACTIVE}.Full`

       - - -  Inactive Full - - -

`cat ${INACTIVE}.Full`

     - - -  Active Incremental - - -

`cat ${ACTIVE}.Inc`

    - - -  Inactive Incremental - - -

`cat ${INACTIVE}.Inc`


EOF

cat ${OUTFILE} | mailx -s "NetBackup Schedule Summary from `hostname` :^)" 
${EMAIL_ADDR}

cd $HERE

clean_up






--------------7BBBD312628E8FC7B9C939DB--