Sponsored Content
Full Discussion: Backups
Special Forums Hardware Filesystems, Disks and Memory Backups Post 20174 by Solaris on Monday 22nd of April 2002 05:17:38 PM
Old 04-22-2002
if [ -n "$INCLUDEFILE" -o -n "$INCLUDE_ONLY" ] ; then
#There is an extra includefile. Use it.

if [ -n "$INCLUDE_ONLY" ] ; then
INCLUDE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB.only \
| grep -v '^#'`
else
INCLUDE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB.include \
| grep -v '^#'`
fi

if [ -n "$INCLUDE" ] ; then
for FILE_SYS in $INCLUDE #For each file system listed
do
Check_fs_type #Get the type of file system it is
#And add it to the list w/ the type
echo "$CLIENT:$FILE_SYS:$FSTYPE:$REMOTE_OSnR" >> $TMPLIST
echo $N "Adding \"$CLIENT:$FILE_SYS:$FSTYPE:$REMOTE_OSnR\" $C"\
|tee -a $LOG
echo "to backup include list" |tee -a $LOG
if [ -n "$INCLUDE_ONLY" ] ; then
echo " (\"$CLIENT:$FILE_SYS\" is in $CLIENT:$FSTAB.only.)" \
|tee -a $LOG
else
echo " (\"$CLIENT:$FILE_SYS\" is in $CLIENT:$FSTAB.include.)" \
|tee -a $LOG
fi
done
fi
fi

else #Else this is not a full system backup. It has a special include list

Check_fs_type
echo $N "Including \"$CLIENT:$FILE_SYS:$FSTYPE:$REMOTE_OSnR\" $C" |tee -a $LOG
echo "in backup include list." |tee -a $LOG
echo "$CLIENT:$FILE_SYS:$FSTYPE:$REMOTE_OSnR" >> $TMPLIST
fi

else #Else there were problems rsh'ing to this client
if [ $RSH_TO_CLIENT -eq 1 ] ; then
Log_err 1 "WARNING, Could not $L_RSH to $CLIENT. It will not be backed up!"
else
Log_err 1 "WARNING! Could not $R_RSH from $CLIENT to $SERVER. $C"
Log_err 1 "It will not be backed up!"
fi
fi
done #done determining the file systems to backup

#Sometimes, fstab's can be out of date, or incorrect. This sometimes results
#in filesystems being included in the backup which no longer exist
#This section will check to make sure that they exist, and that something is
#in them. (That way, if it's just a mount point left, it won't get backed up.)

echo |tee -a $LOG
echo "Now checking that each file system is a valid directory..."|tee -a $LOG
echo |tee -a $LOG

cp /dev/null $TMPLIST.tmp
Log_err $? "Could not create $TMPLIST.tmp" exit

for LINE in `cat $TMPLIST` #For each filesystem listed in the temporary list
do

#This sets the path for the remote cat,grep,egrep,touch, etc. commands
. ${BINDIR}/rempath.sh

CLIENT=`echo $LINE|awk -F: '{print $1}'`
FILE_SYS=`echo $LINE|awk -F: '{print $2}'`

cat >$TMP/$X.DIR.TEST <<EOF_DIR
#!/bin/sh

if [ -d $FILE_SYS ] ; then
df $FILE_SYS >/dev/null
if [ \$? -gt 0 ] ; then
$R_ECHO "NOTVAL" ; exit
fi
else
$R_ECHO "NODIR" ; exit
fi
[ -z "\`ls $FILE_SYS/\* 2>/dev/null\`" ] || $R_ECHO "NOFILES"
EOF_DIR

Check_if_client_is_remote

# Get name of client operating system and version

chmod 755 $TMP/$X.DIR.TEST
Log_err $? "Could not chmod $TMP/$X.DIR.TEST" exit

[ -n "$RSH_IF_REMOTE" ] && rcp $TMP/$X.DIR.TEST $CLIENT:$TMP

#Run the directory test script on the client
DIRTEST=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $TMP/$X.DIR.TEST`
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_RM -f $TMP/$X.DIR.TEST

if [ -z "$DIRTEST" ] ; then
echo "$LINE" >>$TMPLIST.tmp
else
case $DIRTEST in
NOTVAL )
echo $N "Directory $FILE_SYS is not a valid file system on $CLIENT! $C" \
|tee -a $LOG
echo "It will not be backed up!" |tee -a $LOG
;;
NODIR )
echo $N "Directory $FILE_SYS does not exist on $CLIENT! $C" |tee -a $LOG
echo "It will not be backed up!" |tee -a $LOG
;;
NOFILES )
echo $N "Directory $FILE_SYS on $CLIENT is empty! $C" |tee -a $LOG
echo "It will not be backed up!" |tee -a $LOG
;;
esac
fi
done #done making sure that all file systems exist on the client

mv $TMPLIST.tmp $TMPLIST

#Now take each of the file systems and systems listed, and see which backup
#command should be used. If dump is available for that type of file system
#then use it, otherwise, use cpio. (BTW, the reasons to use cpio vs. tar
#were that cpio will preserve the access times of your files, like dump, and it
#will also support an include list from STDIN, so we can still perform
#full an incremental dumps through the use of a touch file.

echo |tee -a $LOG
echo "Determining the appropriate backup commands..." |tee -a $LOG
echo |tee -a $LOG

for LINE in `cat $TMPLIST` #For each filesystem listed in the temporary list
do

#Default values before heading into this case statement

#These two values are hard-coded to make dump think the tape is HUGE.
#I don't use them the way they are written for a lot of reasons.
#But you have to use them on some dumps, or dump will think the tape
#is smaller than it actually is. (Some versions have removed these.)
#THEY DO NOT affect how the data is actually written on the tape

DENSITY='80000'
SIZE='150000'

DUMP=/etc/dump ; RDUMP=/etc/rdump
RESTORE=/etc/restore ; RRESTORE=/etc/rrestore
D_OPTS="${LEVEL}bdsfnu~$B_FACTOR~$DENSITY~$SIZE"
R_OPTS="tbfy~$B_FACTOR"

#Get the Client's OS and file system type from the list
CLIENT=`echo $LINE|awk -F: '{print $1}'`
REMOTE_OSnR=`echo $LINE|awk -F: '{print $4}'`
export REMOTE_OSnR
FSTYPE=`echo $LINE|awk -F: '{print $3}'`

# Get name of client operating system and version

case $REMOTE_OSnR in
*aix* )
case $FSTYPE in
jfs )
DUMP=/usr/sbin/backup ; RDUMP=/usr/sbin/rdump
RESTORE=/usr/sbin/restore ; RRESTORE=/usr/sbin/rrestore

#AIX's restore asks for a -q option to keep from prompting for a tape,
#But it only wants it on restore, not rrestore
#Also backup wants -c, where rdump wants old -d and -s

if [ $SERVER = $CLIENT ] ; then
R_OPTS="-tvy~-q~-b~$B_FACTOR~-f"
D_OPTS="-${LEVEL}~-b~${B_FACTOR}~-c~-u~-f"
else
R_OPTS="-tvy~-b~$B_FACTOR~-f"
D_OPTS="-${LEVEL}~-b~${B_FACTOR}~-d~${DENSITY}~-s~${SIZE}~-c~-u~-f"
fi

;;
* )
DUMP=/usr/bin/cpio
;;
esac
;; #end of aix
*bsdi* )
case $FSTYPE in
ufs )
;;
* )
DUMP=/usr/bin/pax
;;
esac
;; #enc of bsdi
*convex* )
case $FSTYPE in
4.2 )
;;
* )
DUMP=/bin/cpio
;;
esac
;; #end of convex
*dgux* )
case $FSTYPE in
dg/ux )
;;
* )
DUMP=/usr/bin/cpio
;;
esac
;; #end of dgux
*freebsd* )
case $FSTYPE in
ufs )
;;
* )
DUMP=/usr/bin/cpio
;;
esac
;; #end of freebsd
*hpux9* )
case $FSTYPE in
hfs )
DUMP=/etc/dump ; RDUMP=/etc/rdump
RESTORE=/etc/restore ; RRESTORE=/etc/rrestore
;;
vxfs )
DUMP=/etc/vxdump ; RDUMP=/etc/vxdump
RESTORE=/etc/vxrestore ; RRESTORE=/etc/vxrestore
;;
* )
DUMP=/bin/cpio
;;
esac
;; #end of hp9
*hpux10* )
case $FSTYPE in
hfs )
DUMP=/usr/sbin/dump ; RDUMP=/usr/sbin/rdump
RESTORE=/usr/sbin/restore ; RRESTORE=/usr/sbin/rrestore
;;
vxfs )
DUMP=/usr/sbin/vxdump ; RDUMP=/usr/sbin/rvxdump
RESTORE=/usr/sbin/vxrestore ; RRESTORE=/usr/sbin/rvxrestore
;;
* )
DUMP=/usr/bin/cpio
;;
esac
;; #end of hp10
*irix* )
case $FSTYPE in
efs )
;;

xfs )

B_SIZE=`expr $B_FACTOR \* 1024`
if [ "$XFSDUMP" = YES ] ; then
DUMP=/usr/sbin/xfsdump ; RDUMP=/usr/sbin/xfsdump
RESTORE=/sbin/xfsrestore ; RRESTORE=/sbin/xfsrestore
D_OPTS="-m~-b~$B_SIZE~-o~-l~$LEVEL~-F~-f"
R_OPTS="-t~-b~$B_SIZE~-v~silent~-m~-J~-F~-f"
else
DUMP=/sbin/cpio
fi

;;
* )
DUMP=/sbin/cpio
;;
esac
;; #end of irix
*linux* )
#The dump/restore package is an optional install under Linux, and it could also be in
#multiple locations, so we have this elaborate test to see if it is there and where it is.

cat >$TMP/$X.DUMP.TEST <<EOF_DUMP
#!/bin/sh

for CMD in dump restore rdump rrestore cpio
do
if [ -f /sbin/\$CMD ] ; then
echo "\$CMD=/sbin/\$CMD"
else
if [ -f /usr/sbin/\$CMD ] ; then
echo "\$CMD=/usr/sbin/\$CMD"
else
if [ -f /bin/\$CMD ] ; then
echo "\$CMD=/bin/\$CMD"
else
if [ -f /usr/bin/\$CMD ] ; then
echo "\$CMD=/usr/bin/\$CMD"
fi
fi
fi
fi
done
EOF_DUMP

Check_if_client_is_remote

chmod 755 $TMP/$X.DUMP.TEST
Log_err $? "Could not chmod $TMP/$X.DUMP.TEST" exit

[ -n "$RSH_IF_REMOTE" ] && rcp $TMP/$X.DUMP.TEST $CLIENT:$TMP

#Run the dump test script on the client
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $TMP/$X.DUMP.TEST >$TMP/$X.DUMP.TEST.OUT
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_RM -f $TMP/$X.DUMP.TEST

#Look for the commands, and make some variables called LIN_ for Linux dump/restore, etc.

LIN_DUMP=`grep '^dump=' $TMP/$X.DUMP.TEST.OUT |awk -F= '{print $2}'`
LIN_RESTORE=`grep '^restore=' $TMP/$X.DUMP.TEST.OUT |awk -F= '{print $2}'`
LIN_RDUMP=`grep '^rdump=' $TMP/$X.DUMP.TEST.OUT |awk -F= '{print $2}'`
LIN_RRESTORE=`grep '^rrestore=' $TMP/$X.DUMP.TEST.OUT |awk -F= '{print $2}'`
LIN_CPIO=`grep '^cpio=' $TMP/$X.DUMP.TEST.OUT |awk -F= '{print $2}'`

#If any of the dump/restore commands weren't found, use cpio instead

if [ -z "$LIN_DUMP" -o -z "$LIN_RDUMP" -o -z "$LIN_RESTORE" -o -z "$LIN_RRESTORE" ] ; then
LIN_DUMP=$LIN_CPIO ; LIN_RDUMP=$LIN_CPIO ; LIN_RESTORE=$LIN_CPIO ; LIN_RRESTORE=$LIN_CPIO
fi

case $FSTYPE in
ext*|ufs|sysv )
DUMP=$LIN_DUMP ; RDUMP=$LIN_RDUMP
RESTORE=$LIN_RESTORE ; RRESTORE=$LIN_RRESTORE
;;
* )
DUMP=$LIN_CPIO
;;
esac
;; #end of linux
*sysv4* )
case $FSTYPE in
ufs )
DUMP=/usr/sbin/ufsdump ; RDUMP=$DUMP
RESTORE=/usr/sbin/ufsrestore ; RRESTORE=$RESTORE
;;
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

backups

When using hostdump.sh to backup a system I can do it fine. But how can I restore what I backuped up? :) Thx in advance (2 Replies)
Discussion started by: merlin
2 Replies

2. UNIX for Advanced & Expert Users

UNIX backups

hi, how do we go for the BACK UPS on the UNIX box,using DLT tapes.i need to back up the stuff on the DLT tape. pls HELP:( (4 Replies)
Discussion started by: saood
4 Replies

3. UNIX for Dummies Questions & Answers

Backups.

Hello everyone my ? is about backups. I'am running SCO OS 505 and currently backing up the hole HD. Well the back up is taking too long and this is becoming a problem for the users since we are a 24-7 bussines, I whant stop backing up every thing on the HD. What are the most important files and... (1 Reply)
Discussion started by: kikkin
1 Replies

4. UNIX for Advanced & Expert Users

backups in background

Hi, how i can do background backup process in Unix?? I has Solaris Operating System. very much thanks!! (4 Replies)
Discussion started by: jairog
4 Replies

5. UNIX for Dummies Questions & Answers

restoring backups

okay.. pple.. say now i got an aix box. of course i could restore a backup done in aix environment. 1) now how about doing a restore from sun, hp from the aix box.? 2) can we install a sun, hp os into an aix box? 3) if (1) prohibits, then how about doing an sun, hp os installation on... (1 Reply)
Discussion started by: yls177
1 Replies

6. UNIX Desktop Questions & Answers

Backups too CD

I've been handed the task of backing up some of our system files on a Solaris box. No probs. Zipped the logs that needed backing up but my superiors do not want it on tape, they want it spanned on CD's. The CD-Writer is available on a MS box. FTP'd the zipped logs across too the MS Machine but now... (1 Reply)
Discussion started by: mccrack_2003
1 Replies

7. UNIX and Linux Applications

Oracle 9i - Backups

Is there a way to backup an Oracle 9i database without the use of OEM and OMS? (1 Reply)
Discussion started by: adelsin
1 Replies

8. AIX

AIX 6.1 Backups

Hello, I've got multiple AIX LPARs running on VIOS, within a blade environment. I need to dump a mksysb backup to backup rootvg and a couple of other volume groups. mksysb -i "destination"; works however I'd like to make sure its being done correctly. on the other volume groups, ive... (2 Replies)
Discussion started by: ollie01
2 Replies

9. Shell Programming and Scripting

Backups using rsync

Hello all, I'm using nas4free as a SAN and am having troubles getting a backup of it's data to work properly. I've posted in the nas4free forums, but haven't received much help. Here is the code I'm using: #!/bin/sh {... (1 Reply)
Discussion started by: dpatino
1 Replies
All times are GMT -4. The time now is 12:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy