Backups


 
Thread Tools Search this Thread
Special Forums Hardware Filesystems, Disks and Memory Backups
# 1  
Old 04-22-2002
Backups

I have been using the hostdump.sh backup script for over a year now and have recently run into a problem. I'm now getting the following error at the end of my jobs;
/bin/mt -f: error fsf'ing tape.

This script uses the native 'ufsdump'. So, I try to go back and read the last dump on the tape (ufsrestore) and I get the response;
Media read error: Error 0

I have tried removing the last file system backed up from the job, but I get the same error from even other machines that are put on the tape. I can read all the other volumes on the tape with no problems, just the last one is failing. This is the HP DLT80e drive and I have used a cleaner tape recently. I've cycled the power on both the tape drive and the host machine. I have also tried retensioning the tape before running the backup. This has happened on at least 10 different tapes, so I know it's not the media. There isn't much to maintaining this drive, I have followed all that HP has outlined. Another funny thing is that I have manually run a backup on a single machine and that completed with no errors. This is an odd problem, but if anyone has encountered anything similar, please let me know. Thank you.
# 2  
Old 04-22-2002
Post the script - that would help.

What changed recently?

Post the amount of data you are backing up - it may be that you are filling up the tape and it has no way to let you know - is this script run manually or via cron? Do you have output from the cron job if it is one?

What version of OS (and what OS unless we are suppose to just assume by your name it's Solaris)?
thehoghunter
# 3  
Old 04-22-2002
Nothing has changed recently. These backups are incremental backups totalling anywhere from 2 to 10 GB (on 80 GB media). This is started via cron running on Solaris 7 SPARC. I have checked the cron logs and it shows a start and finish time. Can I send an attachment? The script is too long to put into a post.
# 4  
Old 04-22-2002
Please post the cron entry.

Does root get an email when there is a problem? If so, can you post that?

Can you post attachments? I don't know but I know I can't.
Post the script anyway.

I checked Sunsolve for "error fsf'ing tape" - nothing showed for that error. If you are doing some kind of calculation to figure out how many files (dumps) to skip forward, then it's possible:
1. Your calculation is off and you are going beyond the end of the tape
2. One of the dumps is failing in a way that doesn't show and that is throwing off how many dumps are actually on the tape.

I just want to make this clear - you wrote "These backups are incremental backups totalling anywhere from 2 to 10 GB (on 80 GB media). " Is this a total of 10GB or anywhere from 2 to 10 GB a piece for each dump? (meaning you could still be reaching your 80GB limit OR maybe a flag isn't set correctly - also insure your tapes ARE okay for 80GB).
thehoghunter
# 5  
Old 04-22-2002
The only thing root gets emailed is the log file which is where I find the error message "error fsf'ing tape". As far as the size is concerned, the total amount going onto a single tape each night would not normally exceed 10 GB. I'll post the script in fragments. I think it'll take 5 posts. Here goes.

hostdump.sh:

#!/bin/sh
#
#
###################################################################
#
# Rcs_ID="$RCSfile: hostdump.sh,v $"
# Rcs_ID="$Revision: 1.34 $ $Date: 2000/12/14 09:36:05 $"
#
# Authors: Curtis Preston
# (Inspired by a script written by Andrew Blair that backed up Ultrix systems.)
#
###################################################################
#

BINDIR="CHANGEME"

if [ "$BINDIR" = "CHANGEME" ] ; then
echo "You must change the value of BINDIR in $0 to the name"
echo "of the directory where you installed $0 and accompanying"
echo "scripts."
fi

Usage()
{
[ "$DEBUG" = Y ] && set -x
echo "
Usage: $SCRIPT level device log_file system_list

Where:
level = Valid dump level (e.g. 0-9)
device = NO REWIND Tape Drive (e.g. /dev/rmt/0cn)
OR, a directory to backup to (e.g. a removable zip disk)
log_file = FULL Pathname of log file for this backup
system_list = List of systems or file systems to back up

Examples:

$SCRIPT 0 /dev/rmt/0n /tmp/backup/log apollo elvis bambi

$SCRIPT 0 /zipdrive/backupdir /tmp/backup/log apollo elvis bambi

You can give just a list of system names to $SCRIPT. If you do do this,
this script will automatically backup all filesystems on the systems that
you list, excluding any that you list in a file called /etc/\$FSTAB.exclude.
(Where \$FSTAB is the name of the fstab file for that platform. For example,
on Solaris you would have an /etc/vfstab.exclude.)

$SCRIPT 0 /dev/rmt/0n /tmp/backup/log apollo:/ apollo:/usr elvis:/ bambi:/

If you list the file systems one by one, as in the second option above,
it will backup ONLY those filesystems that you list."

}
Log_err()
{
[ "$DEBUG" = Y ] && set -x
#This function determines the success of a previous command, and performs
#the following actions: Puts the error in a log that will be mailed and in
#the master log for this session, and exits the script after running the mail
#function (if the third argument is "exit").

STATUS=$1 ; ERR_MESS=$2
if [ $STATUS -gt 0 ] ; then
echo
echo "$ERR_MESS" >> $TMP/$X.MAIL.LOG
[ -n "$LOG" ] && echo "$ERR_MESS" >> $LOG
if [ "$3" = exit ] ; then
Mail_logs
exit 1
fi
fi
}
Mail_logs()
{
[ "$DEBUG" = Y ] && set -x
#The only thing that is put in the MAIL.LOG is errors, so if there are
#any, then mail them with notification
if [ -s $TMP/$X.MAIL.LOG ] ; then
echo
echo "Backup error message from $SERVER, trying to do a backup." \
|tee $TMP/$X.MAIL.TMP
echo "$SCRIPT received these arguments: $ARGS" | tee -a $TMP/$X.MAIL.TMP
cat $TMP/$X.MAIL.LOG | tee -a $TMP/$X.MAIL.TMP
cat $TMP/$X.MAIL.TMP | $L_MAIL $L_S "Backup_Status" $ADMINS
else
if [ -n "$SUCCESSMAIL" ] ; then
echo "The following backup completed with no errors:" >$TMP/$X.MAIL.TMP
echo "$SCRIPT $ARGS" >> $TMP/$X.MAIL.TMP
cat $TMP/$X.MAIL.TMP | $L_MAIL $L_S "Backup_Status" $ADMINS
fi
fi
[ -n "$TMP/$X*" ] && rm -f $TMP/$X.* $TMP/BACKUP.LABEL
}
Check_fs_type()
{
[ "$DEBUG" = Y ] && set -x
case $REMOTE_OSnR in
*aix* )
#This awk line is required to turn the multi-line, stanza format
#of aix's /etc/filesystems into a single-line variable
FSTYPE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB |grep -v '^\*' \
|awk '$0 ~ /^\/.*:/ { printf $0 } $0 ~ /vfs.*=/ { print $0 }' \
|sed 's/ //g' \
|sed 's/[ ][ ]*vfs[ ][ ]*=[ ][ ]*//' \
|grep "^/" |egrep -v ':cdrfs|:nfs|/tmp:' \
|grep "$FILE_SYS:"|awk -F: '{print $2}'`
;;
*bsdi*|*dgux*|*freebsd*|*next*|*osf*|*irix*|*ultrix*|*sunos*|*convex*|*linux*)
FSTYPE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -v '^#|:' \
| egrep "^/|#.*advfs" |grep -v '#.*#.*advfs' |awk '{ print $2":"$3 }' \
| egrep -v ':swap|:nfs|Smilieroc|:iso9660|:nucfs|:dos|:cd*fs' \
| egrep -v ':rfs|:tmp|:hsfs|:swapfs|:ignore|Smilierocf*s*'\
| egrep -v 'Smiliecfs|:dos|:msdos|/tmp:|^\(.*\):' \
|grep "$FILE_SYS:"|awk -F: '{print $2}'`
;;
*hpux9* )
FSTYPE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -v '^#|:' \
| grep "^/" |awk '{ print $2":"$3 }' \
| egrep -v ':swapf*s*|:nfs|Smilieroc|:cdfs|:ignore' \
| egrep -v '/tmp:|^\(.*\):' \
|grep "$FILE_SYS:"|awk -F: '{print $2}'`
;;
*hpux10* )
FSTYPE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -v '^#|:' \
| grep "^/" |awk '{ print $2":"$3 }' \
| egrep -vi ':swapf*s*|:nfs|:ignore|:cdfs|:nfs' \
| egrep -v '/tmp:|^\(.*\):' \
|grep "$FILE_SYS:"|awk -F: '{print $2}'`
;;
*sysv4*)
FSTYPE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -v '^#|:' \
| grep "^/" | awk '{ print $3":"$4 }' \
| egrep -v ':swap|:nfs|Smilierocf*s*' \
| egrep -v '/tmp:|/dev/fd:|/dev/dsk/f' \
|grep "$FILE_SYS:"|awk -F: '{print $2}'`
;;
*sco* )
#This awk line is required because sco's fstab can go over multiple lines
#each ending with a '\' until the last line. This turns them into
#one line, then chops out the extraneous data
FSTYPE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB |egrep -v '^#|:' \
|awk '$NF ~ /\\/ { printf $0 } $NF !~ /\\/ { print $0 }' \
|sed 's/.*mountdir=//'|sed 's/[ ].*fstyp=/:/' \
|sed 's/[ ].*//'egrep -vi ':HS|SmilieOS' \
|grep "$FILE_SYS:"|awk -F: '{print $2}'`
;;
*solaris* )
FSTYPE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -vi ':|^#' \
|grep '^/' |awk '{ print $3":"$4 }' \
|egrep -v ':swap|:nfs|:hsfs|Smilieroc|-:|/tmp:|/dev/fd:' \
|grep "$FILE_SYS:"|awk -F: '{print $2}'`
;;
esac
[ -n "$FSTYPE" ] || FSTYPE=unk
}

Check_if_client_is_remote()
{
[ "$DEBUG" = Y ] && set -x
if [ $CLIENT = $SERVER ] ; then
RSH_IF_REMOTE=
CLIENT_IF_REMOTE=
else
RSH_IF_REMOTE=$L_RSH
CLIENT_IF_REMOTE=$CLIENT
fi
export RSH_IF_REMOTE CLIENT_IF_REMOTE
}

#Essential variables, that are needed even if we bomb out...


if [ ! -f $BINDIR/hostdump.sh ] ; then
echo "There is a variable called BINDIR in this script, and it is"
echo "either NOT set, or is set to the incorrect value."
echo "Please edit $0 and set it to the name of the directory in which"
echo "you installed this script."
exit 1
fi

L_MAIL=mail
L_S=''
MESS=''
export BINDIR L_MAIL L_S MESS

#Set this variable to Y to turn on set -x for all functions
DEBUG=N
[ "$DEBUG" = Y ] && set -x

#config.guess is the GNU platform guessing script. Check to make sure it's there
if [ ! -f ${BINDIR}/config.guess -o ! -x ${BINDIR}/config.guess ] ; then
Log_err $? "${BINDIR}/config.guess is missing or not executable!
You may need to change the BINDIR variable in $0 to where you placed
config.guess and $0.
You may also need to set it's executable bit (chmod 755 config.guess)." exit
fi

#If you want to TRY to back up IRIX xfs file systems via the xfsdump program,
#Set the following variable to "YES." Warning: Your mileage may vary
#significantly backing up to other OS's, but it can work. If you have
#ANY problems, just change this variable to NO (the default), and
#it will default back to cpio for xfs file systems

XFSDUMP=YES

SERVER=`uname -n 2>/dev/null|awk -F'.' '{print $1}'`
#If it doesn't return anything, try hostname
[ -n "$SERVER" ] || SERVER=`hostname|awk -F'.' '{print $1}'`

#Use config.guess to get OS-n-Revision (OSnR)
LOCAL_OSnR=`${BINDIR}/config.guess`
export LOCAL_OSnR

#List of id's to be mailed upon success or failure
ADMINS="root"

#Will only mail on error if SUCCESSMAIL set to no
SUCCESSMAIL=no

SCRIPT=`basename $0`
X=$$
ARGS=$*
TMP=/usr/tmp
DAY=`date +"%a"`
TMPDF=$TMP/$X.$SERVER
DEVSHORT=`echo $2|sed 's-/--g'`
export LOCAL_OSnR ADMINS SUCCESSMAIL SCRIPT X ARGS TMP DAY TMPDF DEVSHORT

#Most systems don't add much performance after a 64k blocking factor
#So I have hard-coded it to be 64. Feel free to change it, but make
#sure you test it, to make sure you OS can write AND READ at the B_FACTOR
B_FACTOR=64

TMPLIST="$TMP/$X.$SCRIPT.$SERVER.$DEVSHORT.tmp.list"
INCLIST="$TMP/$X.$SCRIPT.$SERVER.$DEVSHORT.list"
export B_FACTOR TMPLIST INCLIST

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

##############################################################

PATH=/bin:/usr/bin:/etc:/bin:/usr/ucb:/usr/sbin:/sbin:/usr/bsd:/usr/local/bin
export PATH

#Check for -h flag asking for help on command
if [ "$1" = -h ] ; then
Usage ; exit
fi

ARGNUM=$#
LEVEL=$1
DEVICE=$2
LOG=$3
[ $ARGNUM -gt 3 ] && shift 3 #This will leave a list of clients
CLIENTS="$*"

. ${BINDIR}/localpath.sh

#Check for sufficient number of arguments
if [ $ARGNUM -lt 4 ] ; then
Usage ; Log_err 1 "$SCRIPT (Missing arguments!): $ARGS" exit
fi

# validate the arguments
#

if [ $LEVEL -gt 9 -o $LEVEL -lt 0 ] ; then
Log_err 1 "Invalid level for $DUMP (Should be 0-9): $LEVEL" exit
fi

TAPE=Y #Set default value of TAPE to Y, unless the DEVICE changes it

if [ ! -c $DEVICE ] ; then
#If it's not a character device, then it must be a directory
if [ -d $DEVICE ] ; then
#If the backup device that you've specified is a directory, then backup to disk
TAPE=N
DEVICE_BASE=$DEVICE/hostdumps
[ -d $DEVICE_BASE ] || mkdir $DEVICE_BASE
else
#If it's not a directory, and it's not a character device, it's not right!
Log_err 1 "Invalid device (Not a character device or a directory): $DEVICE" exit
fi
fi

cp /dev/null $LOG
Log_err $? "Could not create output file: $LOG" exit
# 6  
Old 04-22-2002
echo "==========================================================" |tee -a $LOG
echo "Beginning level $LEVEL backup of the following" |tee -a $LOG
echo "clients: $CLIENTS" |tee -a $LOG
echo "This backup is going to $SERVER:$DEVICE" |tee -a $LOG
echo "and is being logged to $SERVER:$LOG" |tee -a $LOG
echo "==========================================================" |tee -a $LOG

#LOGDIR will get lots of logs during this backup that you can use to check
#status. Each file system gets a separate log, and each host gets two logs,
#the one for this backup, and a running log for history purposes

BACKUPHOME=/var/log
[ -d $BACKUPHOME ] || mkdir $BACKUPHOME
Log_err $? "Could not verify or create $BACKUPHOME: $LOG" exit
LOGDIR=${BACKUPHOME}/backuplogs
[ -d $LOGDIR ] || mkdir $LOGDIR
Log_err $? "Could not verify or create $LOGDIR: $LOG" exit

#The script will now take the list of servers to back up, and check their
#"fstab" files, and create its own list of file systems to back up.
#It can also support being given a special list to use from the command
#line.

echo | tee -a $LOG
echo "Querying clients to determine which file systems to back up..." \
|tee -a $LOG
echo | tee -a $LOG

for INCLUDE_HOST in $CLIENTS
do

#Zero out these values, because we check them for that
CLIENT= ; FILE_SYS=

#Allow for "Partial" feature.
#User can list hostname:/file_system on the command line, instead of
#just the hostname. If that is done, only that file system will be
#backed up on that host

if [ -n "`echo $INCLUDE_HOST|grep ':' `" ] ; then
CLIENT=`echo $INCLUDE_HOST|awk -F: '{print $1}'`
FILE_SYS=`echo $INCLUDE_HOST|awk -F: '{print $2}'`
else
CLIENT=$INCLUDE_HOST
fi
export CLIENT FILE_SYS

Check_if_client_is_remote

# Get name of client operating system and version
if [ -n "$RSH_IF_REMOTE" ] ; then
rcp ${BINDIR}/config.guess $CLIENT:$TMP
else
cp ${BINDIR}/config.guess $TMP
fi

RSH_TO_CLIENT1=$?

REMOTE_OSnR=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $TMP/config.guess`
RSH_TO_CLIENT2=$?
export REMOTE_OSnR

#If either of these fail, this will be non-zero
RSH_TO_CLIENT=`expr $RSH_TO_CLIENT1 + $RSH_TO_CLIENT2`

#This section is designed to see if this client can rsh back to this
#Host. If it cannot, then it cannot be backed up
#Also, this is a good time to rsh over and touch the dumpdates file
#This is because many versions of dump will not create this file if it
#isn't already there.

. ${BINDIR}/rempath.sh

case $REMOTE_OSnR in
*aix* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*bsdi* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*dgux* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*freebsd* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*hpux9* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*hpux10* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /var/adm/dumpdates ;;
*irix* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*sysv4* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*next* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*osf* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/vdumpdates ;;
*sco* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/ddates ;;
*sunos* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*solaris* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
*ultrix* ) $RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_TOUCH /etc/dumpdates ;;
esac

#Remove the file if it is there, then tell the client to create it
rm -f $TMP/$X.$CLIENT.touchfile 2>/dev/null

if [ $SERVER = $CLIENT ] ; then
touch $TMP/$X.$CLIENT.touchfile
else
$L_RSH $CLIENT "$R_RSH $SERVER $L_TOUCH $TMP/$X.$CLIENT.touchfile"
fi

#If it's there, then the rsh worked, if not, it failed
[ -f $TMP/$X.$CLIENT.touchfile ] && RSH_FROM_CLIENT=0 || RSH_FROM_CLIENT=1

case $REMOTE_OSnR in
*aix* )
FSTAB=/etc/filesystems
;;
*bsdi*|*dgux*|*freebsd*|*next*|*osf*|*irix*|*ultrix*|*sunos*|*convex*|*linux*)
FSTAB=/etc/fstab
;;
*hpux9* )
FSTAB=/etc/checklist
;;
*hpux10* )
FSTAB=/etc/fstab
;;
*sysv4*)
FSTAB=/etc/vfstab
;;
*sco* )
FSTAB=/etc/default/filesys
;;
*solaris* )
FSTAB=/etc/vfstab
;;
esac
export FSTAB


if [ $RSH_TO_CLIENT -eq 0 -a $RSH_FROM_CLIENT -eq 0 ] ; then
if [ -z "$FILE_SYS" ] ; then

#Then this is supposed to be a full system backup
#So parse the "fstab" file for a list of all filesystems

INCLUDE_EXCLUDE_SH=$X.FSTAB.exclude.include.sh

echo "#!/bin/sh" > $TMP/$INCLUDE_EXCLUDE_SH
Log_err $? "Could not create $TMP/$INCLUDE_EXCLUDE_SH" exit

echo "[ -f $FSTAB.\$1 ] && $R_LS $FSTAB.\$1" >> $TMP/$INCLUDE_EXCLUDE_SH
Log_err $? "Could not create $TMP/$INCLUDE_EXCLUDE_SH" exit

chmod 755 $TMP/$INCLUDE_EXCLUDE_SH
Log_err $? "Could not chmod $TMP/$INCLUDE_EXCLUDE_SH" exit

if [ $SERVER != $CLIENT ] ; then
rcp $TMP/$INCLUDE_EXCLUDE_SH $CLIENT:$TMP
fi

INCLUDE_ONLY=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $TMP/$INCLUDE_EXCLUDE_SH \
only`

if [ -z "$INCLUDE_ONLY" ] ; then

#If there is an "$VFSTAB.only" file, that means to back up only the
#file systems listed in it. If there is NO such file, go ahead and
#parse the fstab file.

case $REMOTE_OSnR in
*aix* )
#This awk line is required to turn the multi-line, stanza format
#of aix's /etc/filesystems into a single-line variable
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB |grep -v '^\*' \
|awk '$0 ~ /^\/.*:/ { printf $0 } $0 ~ /vfs.*=/ { print $0 }' \
|sed 's/ //g' \
|sed 's/[ ][ ]*vfs[ ][ ]*=[ ][ ]*//' \
|grep "^/" |egrep -v ':cdrfs|:nfs|/tmp:' >$TMPDF
;;
*bsdi*|*dgux*|*freebsd*|*next*|*osf*|*irix*|*ultrix*|*sunos*|*convex*|*linux*)
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -v '^#|:' \
| egrep "^/|#.*advfs" |grep -v '#.*#.*advfs' |awk '{ print $2":"$3 }' \
| egrep -v ':swap|:nfs|Smilieroc|:iso9660|:nucfs|:dos|:cd*fs' \
| egrep -v ':rfs|:tmp|:hsfs|:swapfs|:ignore|Smilierocf*s*' \
| egrep -v 'Smiliecfs|:dos|:msdos|/tmp:|^\(.*\):' >$TMPDF
;;
*hpux9* )
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -v '^#|:' \
| grep "^/" |awk '{ print $2":"$3 }' \
| egrep -v ':swapf*s*|:nfs|Smilieroc|:cdfs|:ignore' \
| egrep -v '/tmp:|^\(.*\):' >$TMPDF
;;
*hpux10* )
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -v '^#|:' \
| grep "^/" |awk '{ print $2":"$3 }' \
| egrep -vi ':swapf*s*|:nfs|:ignore|:cdfs|:nfs' \
| egrep -v '/tmp:|^\(.*\):' \
>$TMPDF
;;
*sysv4*)
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -v '^#|:' \
| grep "^/" | awk '{ print $3":"$4 }' \
| egrep -v ':swap|:nfs|Smilierocf*s*' \
| egrep -v '/tmp:|/dev/fd:|/dev/dsk/f' >$TMPDF
;;
*sco* )
#This awk line is required because sco's fstab can go over multiple lines
#each ending with a '\' until the last line. This turns them into
#one line, then chops out the extraneous data
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB |egrep -v '^#|:' \
|awk '$NF ~ /\\/ { printf $0 } $NF !~ /\\/ { print $0 }' \
|sed 's/.*mountdir=//'|sed 's/[ ].*fstyp=/:/' \
|sed 's/[ ].*//'egrep -vi ':HS|SmilieOS' >$TMPDF
;;
*solaris* )
$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB | egrep -vi ':|^#' \
|grep '^/' |awk '{ print $3":"$4 }' \
|egrep -v ':swap|:nfs|:hsfs|Smilieroc|-:|/tmp:|/dev/fd:' >$TMPDF
;;
*)
#have to touch the file, or the rest would barf
touch $TMPDF
Log_err 1 "WARNING, $CLIENT_OS NOT supported, $HOST will not be backed up!"
;;
esac
else
echo '*****************************************************'|tee -a $LOG
echo "WARNING! This client has a $FSTAB.only file!" |tee -a $LOG
echo "ONLY file systems specified in that file will be backed up!" \
|tee -a $LOG
echo '*****************************************************'|tee -a $LOG
#have to touch the file, or the rest would barf
touch $TMPDF
fi

#Include and Exclude Section
#Checks to see if there are any extra file systems to be included, or
#If there are any ones that should be excluded

EXCLUDEFILE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $TMP/$INCLUDE_EXCLUDE_SH \
exclude`
INCLUDEFILE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $TMP/$INCLUDE_EXCLUDE_SH \
include`

[ $SERVER != $CLIENT ] && $L_RSH $CLIENT $R_RM -f $TMP/$INCLUDE_EXCLUDE_SH

for LINE in `cat $TMPDF` #For each file system that was in the "fstab"
do

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

#If there is an exclude file on the client, check to see if this
#File system is in it

if [ -n "$EXCLUDEFILE" ] ; then
EXCLUDE=`$RSH_IF_REMOTE $CLIENT_IF_REMOTE $R_CAT $FSTAB.exclude \
| grep "^${FILE_SYS}$"`
else
EXCLUDE=''
fi

#If it's not in the exclude file, then back it up, if so, then skip it

if [ -z "$EXCLUDE" ] ; then
echo $N "Including \"$CLIENT:$FILE_SYS:$REMOTE_OSnR\" $C" \
|tee -a $LOG
echo "in backup include list." |tee -a $LOG
echo $CLIENT:$LINE:$REMOTE_OSnR >> $TMPLIST
else
echo "Excluding \"$CLIENT:$FILE_SYS\" from backup include list." \
|tee -a $LOG
echo " (\"$FILE_SYS\" is in $CLIENT:$FSTAB.exclude.)" |tee -a $LOG
fi

done
# 7  
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
;;
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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 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

7. 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

8. 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

9. 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
Login or Register to Ask a Question