Networker

Re: [Networker] Simple UNIX Clone script - for use by community

2007-04-04 12:58:48
Subject: Re: [Networker] Simple UNIX Clone script - for use by community
From: "Reed, Ted G [IT]" <Ted.Reed AT SPRINT DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Wed, 4 Apr 2007 11:53:47 -0500
NOTE:  Outlook likes to remove "extra" line breaks sometimes.....which is 
really bad for scripting.  Be sure you check to see if it says "Extra line 
breaks in this message were removed", and if it does, click on the message and 
"Restore line breaks".  Otherwise, the Storage Node name write to file section 
is mangled.  Thanks.
--Ted 

-----Original Message-----
From: EMC NetWorker discussion [mailto:NETWORKER AT LISTSERV.TEMPLE DOT EDU] On 
Behalf Of Reed, Ted G [IT]
Sent: Wednesday, April 04, 2007 11:43 AM
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Subject: [Networker] Simple UNIX Clone script - for use by community

        For those of you looking for a way to clone a subset of your data, or 
clone on multiple storage nodes/libraries, we have recently crafted a nice, 
clean, simple multi-node script that can be setup on your master server in a 
cron (we have it run at :40 of each hour) and will clone, per SSID, whatever 
pool you define for clone.  In our case, we only have a subset of data getting 
cloned.....the 'critical' environments.  To segregate the critical data, we 
push to a critical-only pool, "BR Pool," and only clone that pool.  All 
non-clones go to "One Month" and are not impacted by the script.  Obviously, 
changes in the mminfo line of the script could result in different SSIDs being 
generated (i.e. not just FULL BR Pool savesets from within the last week only 
having a single copy).  
        Looking for feedback on the script, things we haven't noticed that 
might be gotchas...people who'd think this would work for them....etc.  But 
after many many (MANY) iterations of various and sundry clone scripts, most 
MUCH more complex for what is now no apparent reason, we are happy with how 
simply and elegantly this seems to get the job done and we thought we'd share.  
Thanks in advance for your time and attention.
--Ted

========BEGIN SCRIPT========
#!/bin/ksh
#
# Name: clone_script.sh

#*******************
# Script Variables *
#*******************
LOG_DIR="./ssid"
SN_NAMES="./SN_NAMES"
TIME="one week ago"

#*********************************************************************************************
# Change directory used because ps -ef output was too long and was breaking the 
if statement * 
# By using the change directory we shorten the ps -ef output to manageable 
length            * 
#*********************************************************************************************
cd /usr/local/Legato/clone

#******************************************************************************************************
# This writes the storage node names into a text file.  Thus not dependent on a 
config file somewhere *
#******************************************************************************************************
echo "MasterJukebox" > $SN_NAMES
echo "rd=StorageNodeA:Jukebox" >> $SN_NAMES
echo "rd=StorageNodeB:Jukebox" >> $SN_NAMES
echo "rd=StorageNodeC:Jukebox" >> $SN_NAMES
echo "rd=StorageNodeD:Jukebox1" >> $SN_NAMES
echo "rd=StorageNodeD:Jukebox2" >> $SN_NAMES
#********************************************************************************************************
# Verifies the last nsrhost has finished.  Want clone to include most recent 
master backup and bootstrap*
#********************************************************************************************************
while ps -ef | grep nsrhost | grep -v grep
do
  sleep 300
done

#*******************************************************************************
# Section to check for running clones, if not generate list of save sets to be *
# cloned and executes the clone.                                               *
#*******************************************************************************
for SN in $(cat $SN_NAMES)
do
  if ! ps -ef | grep nsrclone | grep $SN | grep -v grep > /dev/null
  then
        mminfo -omo -r ssid -q "!incomplete,pool=BR 
Pool,copies=1,level=full,location='$SN'" -t "$TIME" > $LOG_DIR.$SN
        nsrclone -b "Clone Vault TX" -S -f $LOG_DIR.$SN &
  fi
done
========END SCRIPT========

To sign off this list, send email to listserv AT listserv.temple DOT edu and 
type "signoff networker" in the body of the email. Please write to 
networker-request AT listserv.temple DOT edu if you have any problems with this 
list. You can access the archives at 
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER

To sign off this list, send email to listserv AT listserv.temple DOT edu and 
type "signoff networker" in the body of the email. Please write to 
networker-request AT listserv.temple DOT edu if you have any problems with this 
list. You can access the archives at 
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER