Networker

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

2007-04-06 11:34:58
Subject: Re: [Networker] Simple UNIX Clone script - for use by community (UPDATED)
From: "Pratt, Matthew [IT]" <Matthew.J.Pratt AT SPRINT DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Fri, 6 Apr 2007 10:22:41 -0500
There was a simple problem found in the second copy of clone script that we 
sent out. I used an older version of the code to make the changes that Conrad 
Macina provided. The problem is in the quotes in the mminfo line.

Here is the correct version.

mminfo -omo -r ssid -q "!incomplete,pool=BR 
Pool,copies=1,level=full,location='$JB'" -t "$TIME" > $LOG_DIR.$JB

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

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, some of the code gets mangled.  Thanks.
--Ted 

I'd like to thank Conrad Macina for providing an elegant piece of code to 
replace the ugly 'echo "JUKEBOXNAME" >> FILE' hard code repeats we had in place 
to list all defined jukeboxes.  Why edit when you can look it up and maintain 
dynamic functionality? 
PS.  Reminder that the 'pool=BR Pool' in the mminfo call and the '-b "Clone 
Vault TX"' in the nsrclone are both specific to my environment and should be 
edited to meet your environment's needs.  See previous thread entries for 
greater detail.
----------BEGIN CODE----------


#!/bin/ksh
#
# Name: clone_script.sh

#*******************
# Script Variables *
#*******************
LOG_DIR="./ssid"
JB_NAMES="./JB_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 jukebox names into a text file. *
#**************************************************
echo "show name \n print type:nsr jukebox" | nsradmin -i - | grep "name:" | awk 
'{print $NF}' | tr -d '";' | sort > $JB_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 JB in $(cat $JB_NAMES)
do
  if ! ps -ef | grep nsrclone | grep $JB | grep -v grep > /dev/null
  then
        mminfo -omo -r ssid -q '!incomplete,pool=BR 
Pool,copies=1,level=full,location=$JB' -t $TIME > $LOG_DIR.$JB
        nsrclone -b "Clone Vault TX" -S -f $LOG_DIR.$JB &
  fi
Done

----------END CODE----------

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