#!/usr/bin/ksh
# ################################################################################################
#AUTHOR: Ed Skolnik
#MODIFIED: 2003/02/10 Created
# 2003/03/06 Changed Clone pool from Default Clone to
# GIS Default Clone to allow to recycle to other pools and
# to allow recycle from other pools
#
# This script is used to clone saveset's that were created since the last time
# it was run. We should be running this script daily.
# Processing:
#
# ################################################################################################
# Declare environment variables here
#
passdir='/var/tmp'
dtstamp=$(date +%h%d_%H%M%S)
#
lastrun="$passdir/$(basename $0)_lastrun"
#
tmpssidonly="/tmp/$(basename $0)_ssid_only.$dtstamp"
tmpmessage="/tmp/$(basename $0)_message.$dtstamp"
minusq=""
nsrjb_rc=0
rcx=0
mailto='root'
# ########################################################################################
ck_for_running_savegrp () {
CT=1
while [ `ps -ef|grep -c 'root .*savegrp'` -gt 1 ] ; do
if [ $CT -gt 10 ] ; then
echo "$(basename $0) Never started cloning because backups were running all night! $(ps -ef|grep 'root .*savegrp' ) " > $tmpdisplay_message
display_message A
exit 69
fi
sleep 900
CT=`expr $CT + 1`
done
}
display_message () {
case $1 in
A|a) message_level="ALERT";;
I|i) message_level="INFORMATION";;
W|w) message_level="WARNING";;
*) message_level="";;
esac
if [ -r $tmpmessage -a -w $tmpmessage ]; then
:
else
echo "$(basename $0) Error in calling display_message function "
exit 69
fi
mailx -s"$(basename $0) $(uname -n) $message_level" $mailto < $tmpmessage
echo $tmpmessage
rm $tmpmessage
}
# ########################################################################################
# Main Line
. /.profile
ck_for_running_savegrp
#
if [ "$1" = "fristrun" ]; then
echo "`date +%m/%d/%Y` " > $lastrun
fi
if [ ! -w $lastrun ]; then
echo "Tickler file not writeable or does not exist ERROR \n This file can be re-created with the current date by running this script \n $0 firstrun" >> $tmpmessage
display_message A
exit 16
fi
lrundate=$(cat $lastrun)
lruntime="$(ls -l $lastrun | awk '{print $8}')"
#
minusq="pool='Default',pool='GIS Default',location=STKL40,copies=1,sscreate>$lrundate $lruntime "
#
mminfo -omo -q"$minusq" -r'ssid,volume(6),client(15),level,sscreate(19),name' > $tmpmessage
#
display_message I
#
mminfo -omo -q"$minusq" -r'ssid' >> $tmpssidonly
#
if [ -a $tmpssidonly ]; then
echo "/usr/sbin/nsrclone -b'GIS Default Clone' -S -f $tmpssidonly "
/usr/sbin/nsrclone -b'GIS Default Clone' -S -f $tmpssidonly
rcx=$?
if [ $rcx = 0 ]; then
rm $tmpssidonly
echo "`date +%m/%d/%Y` " > $lastrun
echo "Good Run of nsrclone"
echo "$(basename $0) $(date)" > $tmpmessage
echo "Good Run of nsrclone" >> $tmpmessage
display_message I
else
echo "$(basename $0) Clone failed return code $rcx from nsrclone command " > $tmpmessage
display_message A
fi
else
echo "no clone"
fi
# Clean up temp files over 3 days old
find /tmp -name "$(basename $0)*" -type f -mtime +3 -exec rm {} \;
exit 0
# ######################################### End Of Script #####################################
==================================================
Ed Skolnik
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.