[HPADM] Re: Script to copy /home

From: Eric Berg (eberg@siac.com)
Date: Thu Oct 21 2004 - 14:46:15 EDT


You should check out rsync <http://rsync.samba.org> It's an incremental
file xfer utility, so if you have only a few file changes, only the diffs
will be sent.

-Eric.

Eric Berg
SIAC Unix System Support

                                                                                                                                   
                      brian irvin
                      <brian944us@yahoo.c To: hpux-admin@dutchworks.nl
                      om> cc: (bcc: Eric Berg/SIAC)
                      Sent by: Subject: [HPADM] Script to copy /home
                      hpux-admin-owner@du
                      tchworks.nl
                                                                                                                                   
                                                                                                                                   
                      10/21/2004 02:10 PM
                                                                                                                                   
                                                                                                                                   

Team:

I am writing a small script to copy the home dir's
from 3 machines. Pl find my script below..Please help
if there are any mistakes..My first attempt..

#!/usr/bin/sh

###################################################################
 # SCRIPT NAME : HomeBackup.sh
 # AUTHOR : Brian
 # DATE :
 # VERSION NO : 1.0
 # PURPOSE : This script takes backup of /home
Machines ns1, ns2, ns3 to /home directories to as50
server.
 #

PATH=$PATH:/usr/bin:/usr/sbin:/usrlocal/bin:/usr/contrib/bin:/opt/perf/bin
export TERM=vt100
export PATH

LOG_FILE=/tmp/HomeBackup.log
exec >> $LOG_FILE 2>&1

ns1_Home_Size=`remsh ns1 /usr/bin/bdf |grep home |awk
'{ if ($6 == "/home") print $3 }'`
if [ $? -eq 1 ]
then
             echo "`date '+%D %T'` ns1 remote execution permission
is not available"
             exit 1
fi

ns2_Home_Size=`remsh ns2 /usr/bin/bdf |grep home |awk
'{ if ($6 == "/home") print $3 }'`
if [ $? -eq 1 ]
then
             echo "`date '+%D %T'` ns2 remote execution permission
is not available"
             exit 1
fi
ns3_Home_Size=`remsh ns3 /usr/bin/bdf |grep home |awk
'{ if ($6 == "/home") print $3 }'`
if [ $? -eq 1 ]
then
             echo "`date '+%D %T'` ns3 remote execution permission
is not available"
             exit 1
fi
Total_used_space=`expr $ns1_Home_Size + $ns2_Home_Size
+ $ns3_Home_Size`
Availed_space=`/usr/bin/bdf |grep depot|awk '{ if ($6
== "/depot") print $4 }'`

# Check free space is available on as50:/depot
if [ $Availed_space -lt $Total_used_space ]
then
             echo "`date '+%D %T'` Error: There is not enough
space under /depot "
             exit 1
fi

#Copy ns1 /home directory to as50:/depot/ns1
if [ -f /home/ns1/home ]
then
             rcp -rp ns1/home /depot/ns1/home
fi

#Copy ns2 /home directory to as50:/depot/ns2
if [ -f /home/ns2/home ]
then
             rcp -rp ns2:/home /depot/ns2/home
fi

#Copy ns3 /home directory to as50:/depot/ns3
if [ -f /home/ns3/home ]
then
             rcp -rp ns3:/home /depot/ns3/home
fi

My questions:

Is rcp a good approach or can i use fbackup etc..

Is there anyhting wrong with the script?

Please Help

Best Regards

Brian

_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact
majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner:
owner-hpux-admin@dutchworks.nl
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse
only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse &
search)
-----------------------------------------
This message and its attachments may contain  privileged and confidential
information.  If you are not the intended recipient(s), you are prohibited
from printing, forwarding, saving or copying this email.  If you have
received this e-mail in error, please immediately notify the sender and
delete this e-mail and its attachments from your computer.
--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:44 EDT