Sponsored Content
Full Discussion: Backups
Special Forums Hardware Filesystems, Disks and Memory Backups Post 20176 by Solaris on Monday 22nd of April 2002 05:22:09 PM
Old 04-22-2002
echo "$DUMP $LEVEL NOT Done $DATE from $CLIENT $FILE_SYS on " \
|tee -a $FSLOG
echo "${SERVER}:${DEVICE} $COUNT" |tee -a $FSLOG

fi

#This next section is for the xfsdump command, which makes multiple
#tape files per dump!

FILECOUNT=`grep ' media file [0-9]' $FSLOG |tail -1 \
|sed 's/.* media file //' |sed 's/ .*//g'`
[ -n "$FILECOUNT" ] || FILECOUNT=0
FILECOUNT=`expr $FILECOUNT + 1`
sed "s+$LINE+$LINE:$FILECOUNT+" $INCLIST >$TMP/$$.inclist.tmp
mv $TMP/$$.inclist.tmp $INCLIST

COUNT=`expr $COUNT + $FILECOUNT`

cat $FSLOG >> $CURRENT_HOST_LOG

else #Else, it's a remote dump

echo $N "Backing up ${CLIENT}:${FILE_SYS} level $LEVEL $C" |tee -a $FSLOG
echo "(File system ${COUNT})" |tee -a $FSLOG

TMP_DUMP_SH="$X.tmp.dump.script.sh"

if [ $DUMPBASE != cpio ] ; then
#sleep 5
echo $N "Using Command: $L_RSH $CLIENT $RDUMP $D_OPTS $SERVER:$DEVICE $FILE_SYS" |tee -a $FSLOG

#First, we make a little dump shell script that will run on the client

cat >$TMP/$TMP_DUMP_SH <<EOF_TMP_DUMP
#!/bin/sh

$R_CD $FILE_SYS
$R_RM -f $TMP/$X.$FSNAME.$DOPTS.stat 2>/dev/null
$RDUMP $D_OPTS $SERVER:$DEVICE $FILE_SYS 2>&1
$R_ECHO \$? >$TMP/$X.$FSNAME.$DOPTS.stat
EOF_TMP_DUMP

else

echo $N "Using Command: $L_RSH $CLIENT \" $R_CD $FILE_SYS ; $R_TOUCH DO_NOT_REMOVE.level.$LEVEL.cpio.touchfile ; find . -newer DO_NOT_REMOVE.level.`expr $LEVEL - 1`.cpio.touchfile -xdev -print | $DUMP $D_OPTS | ($R_RSH $SERVER $L_DD of=$DEVICE bs=5120 \" )" |tee -a $FSLOG

#First, we make a little cpio shell script that will run on the client

cat >$TMP/$TMP_DUMP_SH <<EOF_R_CPIO.SH
#!/bin/sh

$R_RM -f $TMP/$X.$FSNAME.$DOPTS.stat 2>/dev/null

$R_CD $FILE_SYS
$R_TOUCH DO_NOT_REMOVE.level.$LEVEL.cpio.touchfile
$R_ECHO \$? >> $TMP/$X.$FSNAME.$DOPTS.stat

#To understand how this section works, see the comments in the
#local backup section for the cpio section

if [ $LEVEL -eq 0 ] ; then
NEWER=''
else
$R_TOUCH DO_NOT_REMOVE.level.$LEVEL.cpio.touchfile
FILENUM=\`$R_LS DO_NOT_REMOVE.level* \
|$R_GREP -n "DO_NOT_REMOVE.level\.$LEVEL\." \
|$R_AWK -F: '{print \$1}'\`

[ -n "\$FILENUM" ] || FILENUM=1

FILENUM=\`$R_EXPR \$FILENUM - 1\`

if [ \$FILENUM -eq 0 ] ; then
NEWER=''
$R_TOUCH DO_NOT_REMOVE.level.0.cpio.touchfile
else
NEWER="-newer \`ls DO_NOT_REMOVE.level.*|head -\$FILENUM|tail -1\`"
fi
fi

$R_ECHO \$? >> $TMP/$X.$FSNAME.$DOPTS.stat

[ -n "\`$TMP/config.guess|grep irix\`" ] && XDEV=mount || XDEV=xdev

$R_FIND . \$NEWER -\$XDEV -print | $DUMP $D_OPTS \
|($R_RSH $SERVER $L_DD of=$DEVICE bs=5120 )
$R_ECHO \$? >> $TMP/$X.$FSNAME.$DOPTS.stat

EOF_R_CPIO.SH

Log_err $? "Could not create $TMP/$TMP_DUMP_SH"

fi

#Then we rcp it over and run it
chmod 755 $TMP/$TMP_DUMP_SH
Log_err $? "Could not chmod $TMP/$TMP_DUMP_SH" exit

rcp $TMP/$TMP_DUMP_SH $CLIENT:$TMP/$TMP_DUMP_SH
Log_err $? "Could not rcp $TMP/$TMP_DUMP_SH to $CLIENT" exit

$L_RSH $CLIENT $TMP/$TMP_DUMP_SH |tee -a $FSLOG

RESULT=`$L_RSH $CLIENT $R_SORT -u $TMP/$X.$FSNAME.$DOPTS.stat|tail -1`
#$L_RSH $CLIENT $R_RM -f $TMP/$TMP_DUMP_SH

if [ "$RESULT" = 0 ] ; then

DATE=`date +"%a %D %T"`

echo $N "$DUMP $LEVEL Done $DATE from $CLIENT: $C" |tee -a $FSLOG
echo "$FILE_SYS on ${SERVER}:${DEVICE} $COUNT" |tee -a $FSLOG

else

DATE=`date +"%a %D %T"`

echo $N "$DUMP $LEVEL NOT Done $DATE from $CLIENT $C" |tee -a $FSLOG
echo "$FILE_SYS on ${SERVER}:${DEVICE} $COUNT" |tee -a $FSLOG fi

fi

#This next section is for the xfsdump command, which makes multiple
#tape files per dump!

FILECOUNT=`grep ' media file [0-9]' $FSLOG |tail -1 \
|sed 's/.* media file //' |sed 's/ .*//g'`
[ -n "$FILECOUNT" ] || FILECOUNT=0
FILECOUNT=`expr $FILECOUNT + 1`
sed "s+$LINE+$LINE:$FILECOUNT+" $INCLIST >$TMP/$$.inclist.tmp
mv $TMP/$$.inclist.tmp $INCLIST

COUNT=`expr $COUNT + $FILECOUNT`

$L_RSH $CLIENT $R_RM -f $TMP/$X.$FSNAME.$DOPTS.stat

cat $FSLOG >>$CURRENT_HOST_LOG
Log_err $? "Could not append $FSLOG to $CURRENT_HOST_LOG"

fi

LAST_FILE_SYS=`grep $CLIENT $INCLIST \
| awk -F: '{print $2}' | tail -1 | grep -c "^${FILE_SYS}$"`

if [ $LAST_FILE_SYS -eq 1 ] ; then

if [ -n "$POSTBACKUP" ] ; then
$RSH_IF_REMOTE $CLIENT_IF_REMOTE /usr/local/bin/postbackup.sh |tee -a $CURRENT_HOST_LOG
fi

#Append this file sys's backup log to the current log of this backup
cat $CURRENT_HOST_LOG >> $LOG
Log_err $? "Could not append $CURRENT_HOST_LOG to $LOG"

#Append this backup's log to the running master backup log for this host
cat $CURRENT_HOST_LOG >> $RUNNING_HOST_LOG
Log_err $? "Could not append $CURRENT_HOST_LOG to $RUNNING_HOST_LOG"

#Keep only 10000 lines in the running log
tail -10000 $RUNNING_HOST_LOG >$TMP/$X.running.tmp.log
Log_err $? "Could not create $TMP/$X.running.tmp.log"

cp $TMP/$X.running.tmp.log $RUNNING_HOST_LOG
Log_err $? "Could not cp $TMP/$X.master.tmp.log to $LOG"

fi

done


if [ $COUNT -gt 1 ] ; then
echo "Backups complete... Beginning reading of tape...\n" |tee -a $LOG
#sleep 60

if [ "$TAPE" = Y ] ; then
$L_MT $L_F $DEVICE $L_REWIND
Log_err $? "Tape would not rewind with command: $L_MT $L_F $DEVICE $L_REWIND" exit
fi

echo "Rewind Complete" |tee -a $LOG

#sleep 20

#This must start at '2' because the "label" that is put on the tape is
#Actually the first partition on the tape.

READCOUNT=2

for LINE in `cat $INCLIST`
do

sleep 2

if [ "$TAPE" = Y ] ; then
$L_MT $L_F $DEVICE $L_REWIND
Log_err $? "$L_MT $L_F: error ${L_REWIND}'ing tape." exit
fi

if [ "$TAPE" = Y ] ; then
$L_MT $L_F $DEVICE fsf `expr $READCOUNT - 1`
Log_err $? "$L_MT $L_F: error fsf'ing tape." exit
fi

sleep 2

#Parse out values from the line
CLIENT=`echo $LINE|awk -F: '{print $1}'`
FILE_SYS=`echo $LINE|awk -F: '{print $2}'`
FSTYPE=`echo $LINE|awk -F: '{print $3}'`
REMOTE_OSnR=`echo $LINE|awk -F: '{print $4}'`
export REMOTE_OSnR
DUMP=`echo $LINE|awk -F: '{print $5}'`
RDUMP=`echo $LINE|awk -F: '{print $6}'`
D_OPTS=`echo $LINE|awk -F: '{print $7}'|sed 's/~/ /g'`
DOPTS=`echo $LINE|awk -F: '{print $7}'` #Used to create a unique log file
RESTORE=`echo $LINE|awk -F: '{print $8}'`
RRESTORE=`echo $LINE|awk -F: '{print $9}'`
R_OPTS=`echo $LINE|awk -F: '{print $10}'|sed 's/~/ /g'`
LEVEL=`echo $LINE|awk -F: '{print $11}'`
R_RSH=`echo $LINE|awk -F: '{print $12}'`
B_FACTOR=`echo $LINE|awk -F: '{print $13}'`
FILECOUNT=`echo $LINE|awk -F: '{print $14}'`
FSNAME=`echo ${FILE_SYS}|sed 's-/-_-g'`

[ "$FSNAME" = "_" ] && FSNAME='_root'

if [ "$TAPE" != Y ] ; then
DEVICE="$DEVICE_BASE/${CLIENT}$FSNAME.$DUMPBASE.level.$LEVEL"
touch $DEVICE
fi

DUMPBASE=`basename $DUMP`

echo |tee -a $LOG
echo "=======================================================" |tee -a $LOG
echo $N " Positioning to Pt# $READCOUNT w/cmd: $C" |tee -a $LOG
echo "$L_MT $L_F $DEVICE fsf `expr $READCOUNT - 1`" |tee -a $LOG

echo " Reading File system $CLIENT:$FILE_SYS" |tee -a $LOG
echo " This was a $FSTYPE file system on a $REMOTE_OSnR system."|tee -a $LOG
echo " (It was backed up with $DUMPBASE.)" |tee -a $LOG

if [ $REMOTE_OSnR = $LOCAL_OSnR -a $DUMPBASE != cpio ] ; then

echo " Using Command: $RESTORE $R_OPTS $DEVICE" |tee -a $LOG

$RESTORE $R_OPTS $DEVICE \
|sed "s/^/$DUMPBASE Pt# $READCOUNT: > /" |tee -a $LOG

else

if [ $DUMPBASE = cpio ] ; then
#Read the file w/ cpio

echo $N " Using Command: $L_DD if=$DEVICE bs=5120 $C" |tee -a $LOG
echo "|($L_RSH $CLIENT $RESTORE -ictv )" |tee -a $LOG
echo |tee -a $LOG

$L_DD if=$DEVICE bs=5120|($L_RSH $CLIENT $RESTORE -ictv )\
|sed "s/^/$DUMPBASE Pt# $READCOUNT: > /" |tee -a $LOG

else

echo " Using Command: $L_RSH $CLIENT $RRESTORE $R_OPTS $SERVER:$DEVICE "
echo |tee -a $LOG

$L_RSH $CLIENT $RRESTORE $R_OPTS $SERVER:$DEVICE \
|sed "s/^/$DUMPBASE Pt# $READCOUNT: > /"|tee -a $LOG
fi

fi

Log_err $? "Could not read filesystem $READCOUNT!"

READCOUNT=`expr $READCOUNT + $FILECOUNT`

if [ "$TAPE" = Y ] ; then
$L_MT $L_F $DEVICE $L_REWIND
Log_err $? "$L_MT $L_F: error ${L_REWIND}'ing tape." exit
fi
done

#Append the output log to the tape for disaster purposes
if [ "$TAPE" = Y ] ; then
$L_MT $L_F $DEVICE $L_REWIND
Log_err $? "$L_MT $L_F: error ${L_REWIND}'ing tape." exit

$L_MT $L_F $DEVICE fsf `expr $READCOUNT - 1`
Log_err $? "$L_MT $L_F: error fsf'ing tape." exit
else
DEVICE="$DEVICE_BASE/index.level.$LEVEL"
touch $DEVICE
fi

tar cvf $DEVICE $LOG

echo "Tape read successful..." |tee -a $LOG

if [ -f /usr/local/bin/afterread.sh ] ; then
echo "Running the commands found in /usr/local/bin/afterread.sh" | tee -a $LOG
/usr/local/bin/afterread.sh
fi

if [ "$TAPE" = Y ] ; then
$L_MT $L_F $DEVICE $L_OFFLINE
Log_err $? "$L_MT $L_F: error ${L_OFFLINE}'ing tape." exit
fi

echo "Tape ejected" |tee -a $LOG

fi

Mail_logs

#EOF
 

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 06:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy