Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clone Scripts

Status
Not open for further replies.

b62416

MIS
Joined
Feb 26, 2003
Messages
3
Location
US
Does anyone have any good Perl cloning scripts?
 
#!/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&quot;$(basename $0) $(uname -n) $message_level&quot; $mailto < $tmpmessage
echo $tmpmessage
rm $tmpmessage
}
# ########################################################################################
# Main Line
. /.profile
ck_for_running_savegrp
#
if [ &quot;$1&quot; = &quot;fristrun&quot; ]; then
echo &quot;`date +%m/%d/%Y` &quot; > $lastrun
fi
if [ ! -w $lastrun ]; then
echo &quot;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&quot; >> $tmpmessage
display_message A
exit 16
fi
lrundate=$(cat $lastrun)
lruntime=&quot;$(ls -l $lastrun | awk '{print $8}')&quot;
#
minusq=&quot;pool='Default',pool='GIS Default',location=STKL40,copies=1,sscreate>$lrundate $lruntime &quot;
#
mminfo -omo -q&quot;$minusq&quot; -r'ssid,volume(6),client(15),level,sscreate(19),name' > $tmpmessage
#
display_message I
#
mminfo -omo -q&quot;$minusq&quot; -r'ssid' >> $tmpssidonly

#
if [ -a $tmpssidonly ]; then
echo &quot;/usr/sbin/nsrclone -b'GIS Default Clone' -S -f $tmpssidonly &quot;
/usr/sbin/nsrclone -b'GIS Default Clone' -S -f $tmpssidonly
rcx=$?
if [ $rcx = 0 ]; then
rm $tmpssidonly
echo &quot;`date +%m/%d/%Y` &quot; > $lastrun
echo &quot;Good Run of nsrclone&quot;
echo &quot;$(basename $0) $(date)&quot; > $tmpmessage
echo &quot;Good Run of nsrclone&quot; >> $tmpmessage
display_message I
else
echo &quot;$(basename $0) Clone failed return code $rcx from nsrclone command &quot; > $tmpmessage
display_message A
fi
else
echo &quot;no clone&quot;
fi

# Clean up temp files over 3 days old
find /tmp -name &quot;$(basename $0)*&quot; -type f -mtime +3 -exec rm {} \;
exit 0
# ######################################### End Of Script #####################################




==================================================
Ed Skolnik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top