Veritas-bu

[Veritas-bu] frequency

2001-09-13 14:08:27
Subject: [Veritas-bu] frequency
From: Ken.Zufall AT ps.bellhowell DOT com (Zufall, Ken)
Date: Thu, 13 Sep 2001 14:08:27 -0400
The only problem is that you can't currently specify a particular date/day
of month to run the backup on.  Because of the irregularity in the number of
days per month, this will become skewed in a relatively short time.  It
would require a certain amount of manual upkeep.

I know that W. Curtis Preston has a script to deal with this
(autosched.pl?).  I've also written the following script to schedule monthly
backups on the first Saturday of the month.  It's been working fine, feel
free to use it at your own risk.

#!/usr/bin/ksh
set -x
exec 2>/tmp/monthly.debug

############################################################################
####
## Script: monthly_NBUsched_reset.ksh
##
## Author: Ken Zufall
##
## Date: 07/06/01
##
##
##
## This script is used to allow scheduling of monthly backups on the first
##
## Saturday of the month without manual intervention.  It should be run from
##
## cron the Sunday after the first Saturday; following is proper syntax for
##
## the cron entry:
##
##
##
## 0 21 * * 0 /opt/openv/netbackup/local/bin/monthly_NBUsched_reset.ksh >
##
## /dev/null 2>&1
##
##
##
## 21:00 was chosen as the runtime to avoid any potential contention with
##
## running backups.
##
##
##
## This script is currently targeted at just the Window backups.  It assumes
##
## a consistent naming policy for both class names ([hostname]_FS) and
##
## schedule names (Monthly).
##
##
##
## Revised_Date:
##
## Revised_By:
##
## Reason_for_Revision:
##
##
##
############################################################################
####

###################
## Set Variables
###################

## Not all paths here are necessary, but I like to cover my bases for future

## revisions.

NBU=/opt/openv/netbackup
BIN=$NBU/bin
ADMIN=$BIN/admincmd
GOODIES=$BIN/goodies
CLIENTS=/tmp/nbu_win_client.list
NBU_TMP=$NBU/local/bin/tmp
MAIL_LIST=tapeops

FULL_MONTH=`date +%B`
MONTH=`date +%b`
NUM_DATE=`date +%d`
NUM_YEAR=`date +%y`

## Necessary logic for leap years.  NOTE: This breaks down in Feb of 3000,
which 
## is a leap year.

if [ $MONTH = Feb ] && [ $(( $NUM_YEAR % 4 )) = 0 ] && [ $NUM_YEAR != 00 ];
then
        MONTH=FEB
fi

## Define $LOCK here so that $MONTH is easily recognizable

LOCK=$NBU_TMP/.monthly_lck_$MONTH

case $MONTH in
        Jan|Mar|May|Jul|Aug|Oct|Dec )   MONTH=31_days ;;
        Apr|Jun|Sep|Nov             )   MONTH=30_days ;;
        Feb                         )   MONTH=28_days ;;
        FEB                         )   MONTH=29_days ;;
esac

## Get a list of PC clients from NBU, strip off ".backup-int" portion of
client 
## name.
## Note: If new PC clients are added without the Monthly schedule, errors
will 
## be generated by this script, but classes with the Monthly schedule should

## still be updated properly.

$ADMIN/bpclclients -U -allunique -noheader | grep "PC Win" | awk '{print
$3}' | awk -F. '{print $1}' > $CLIENTS

###################
## Define Functions
###################

## It was decided to reset the schedules to 25 and 30 days for simplicity.
Once ## the frequency is met, NBU will wait until the next window to run.

## 2160000 = number of seconds in 25 days

fn_25days() {
for CLASS in `cat $CLIENTS`; do
        $ADMIN/bpclschedrep ${CLASS}_FS Monthly -freq 2160000
done
}

## 2592000 = number of seconds in 30 days

fn_30days() {
for CLASS in `cat $CLIENTS`; do
        $ADMIN/bpclschedrep ${CLASS}_FS Monthly -freq 2592000
done
}

###################
## Begin Execution
###################

## If $LOCK already exists, don't execute the script.  This is to prevent 
## potential issues with manual execution of the script.

if [ -a $LOCK ]; then
        echo "NBU Monthly Schedule Update has already been run in
$FULL_MONTH, script exiting" | mailx -s "NBU Sched update failed" $MAIL_LIST
        exit
fi

## Depending on day of month and number of days in month, set Monthly
schedules ## to 25 or 30 days.  It was decided to set days for non-leap year
Feb, even 
## though it's not necessary, to aid in prevention of running on the wrong
day--## this was put in place before the inclusion of $LOCK and left because
I like ## the symmetry.

if [ $NUM_DATE -ge 2 ] && [ $NUM_DATE -le 4 ] && [ $MONTH = 31_days ]; then
        fn_30days
elif [ $NUM_DATE -ge 5 ] && [ $NUM_DATE -le 8 ] && [ $MONTH = 31_days ];
then
        fn_25days
elif [ $NUM_DATE -ge 2 ] && [ $NUM_DATE -le 3 ] && [ $MONTH = 30_days ];
then
        fn_30days
elif [ $NUM_DATE -ge 4 ] && [ $NUM_DATE -le 8 ] && [ $MONTH = 30_days ];
then
        fn_25days
elif [ $NUM_DATE -ge 2 ] && [ $NUM_DATE -le 8 ] && [ $MONTH = 28_days ];
then
        fn_25days
elif [ $NUM_DATE = 02 ] && [ $MONTH = 29_days ]; then
        fn_30days
elif [ $NUM_DATE -ge 3 ] && [ $NUM_DATE -le 8 ] && [ $MONTH = 29_days ];
then
        fn_25days
fi

## Send out notification of success or failure of schedule reset.

if [ $? = 0 ]; then
        echo "NBU Monthly Schedule Update succeeded for $FULL_MONTH" | mailx
-s "NBU Schedule update successful" $MAIL_LIST

## If run was successful, remove old lock file and create new.

        /usr/bin/rm -f $NBU_TMP/.monthly_lck_*
        touch $LOCK
else
        echo "NBU Monthly Schedule Update has failed for $FULL_MONTH" |
mailx -s "NBU Schedule update failed" $MAIL_LIST
fi

Ken Zufall
330.202.4113

"You were my only planned child and my only mistake." - My Mother

                -----Original Message-----
                From:   Guy Speier [mailto:guys AT firstlogic DOT com]
                Sent:   Thursday, September 13, 2001 11:24 AM
                To:     'veritas-bu AT mailman.eng.auburn DOT edu'
                Subject:        [Veritas-bu] frequency

                Hello,

                If I create a schedule which has an entry for every day of
the week, 
                and a frequency of every month, will this give me a monthly
full backup?

                My thought here is that I can have another schedule doing
incr's every
                other day, and they just have a full taken once per month.

                Any gotchas?

                thanks,
                Guy
                _______________________________________________
                Veritas-bu maillist  -  Veritas-bu AT mailman.eng.auburn DOT edu
                http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu

<Prev in Thread] Current Thread [Next in Thread>