Forcing good backup procedures

Hendrik Vermooten hendrik at zeusa.UUCP
Tue Nov 27 15:52:45 AEST 1990


About forcing good backup procedures. I got two scripts with possible
solutions, and some mail from various people asking for them, so I
decided to post. (Thanks to sean at kcms and alan at mq).

======================================================================

>From olsa99!kcms!sean Sat Nov 10 04:28:22 1990
Subject: Backup watchdog
From: Sean Enraght-Moony <root at kcms.UUCP>

Howdy do.

I have had a similar problem, although my users are a little more
intelligent.  They still need reminding, however.  They have a 286 XENIX
box with 60Mb tape.  Normally, I think the best tape labeling mechanism
would be to use a "no-rewind" tape device, and use dd to write out a header
to the tape without rewinding.  The backup would follow.  To read the
header, you would use dd to read the first section of the tape (with no
rewind) and then compare it to a value in a disk file.

This is lovely if you have a no-rewind device, which their system doesn't.
What we do, then, is to have a disk file called TVOL which contains the
tape volume name.  We use tar to back up, and the first file name in the
list of files to be backed up is TVOL.  This way, the tape always has the
volume name as part of the data at the same place (in front of the file).
The first thing the backup script does is to work out what the tape volume
should be.  The next task is to read the first part of the tar volume with dd,
and extract the volume name:


# SBE is what the volume name should be
# VOL is what the volume is
# /usr/sys_data is the directory where funny system-wide info is kept

SBE=`dd if=/usr/sys_data/backup.log bs=1 skip=29 count=9 2> /dev/null | head -1`
if	[ `expr ${1:-0}` -lt `expr 1` -o `expr ${1:-0}` -gt `expr 10` ]
then
	echo "Reading tape label . . ."
	VOL=`dd if=/dev/rct0 skip=1 count=1 2> /dev/null | head -1`
else
	case	$1 in
		1)	VOL="BACKUP01"
			;;
		2)	VOL="BACKUP02"
			;;
		3)	VOL="BACKUP03"
			;;
		4)	VOL="BACKUP04"
			;;
		5)	VOL="BACKUP05"
			;;
		6)	VOL="BACKUP06"
			;;
		7)	VOL="BACKUP07"
			;;
		8)	VOL="BACKUP08"
			;;
		9)	VOL="BACKUP09"
			;;
		10)	VOL="BACKUP10"
			;;
	esac
fi
echo $VOL > /TVOL
echo "Installed volume is $VOL, next backup should be on $SBE"
if [ "$VOL" != "$SBE" ]
then
	echo "\007This is possibly the wrong volume!"
fi
while	echo "Do you want to back up onto this tape (y/n)? \c" >&2
do	read YN rest
	case	$YN in
		[yY])	:
			:
		    [ tar backup, TVOL backed up first ]
			:
			:
			echo "`date` $VOL">>/usr/sys_data/backup.log
			tail -10 /usr/sys_data/backup.log > \
				/usr/sys_data/new.backup.log
			rm /usr/sys_data/backup.log
			mv /usr/sys_data/new.backup.log /usr/sys_data/backup.log
			chmod 664 /usr/sys_data/backup.log
			echo "\nFinished\n"
			sleep 10
			clear
			break
			;;
		[nN])	echo "Backup aborted at user's request\n"
			break
			;;
		*)	echo "Please answer y or n" >&2;;
	esac
done


A backup log is maintained in /usr/sys_data/backup.log which lists the last
10 backups.  The next tape volume required is also extracted from here.

I'm sure that with a bit of modification, this would serve your needs.
Having the system mail you in the event of an error would be a piece of
cake.

I hope this is something like what you were looking for?


Regards

Sean

------------------------------------------------------------------------------
Sean Enraght-Moony:  ..!uunet!ddsw1!olsa99!kcms!sean  or  sean at kcms
If, at first, you don't succeed, blame your vendor.
------------------------------------------------------------------------------

======================================================================

>From olsa99!ddsw1!uunet!mq!alan Mon Nov 12 17:23:17 1990
From: olsa99!ddsw1!uunet!mq!alan
To: ddsw1!olsa99!zeusa!hendrik
Date: Sun Nov 11 10:16:47 1990

To: uunet!ddsw1!olsa99!zeusa!hendrik

:
# bakup.sh
#
# Script to verify correct day tape in drive before doing backup.
#
# This script is dependent on the output of dumpdir(C) as found in 
# SCO XENIX 386 SVR2.3.2 and may not work with other versions.
#
# It should be called from cron instead of the normal /bin/backup. Any
# parameters from the cron line are passed to /bin/backup.
#

systemid=`cat /etc/systemid`
admmail="central!sysadm"
onsite="operator"
today=`date +%a`

# Get day of last dump on tape from dumpdir header
tapeday=`dumpdir | head -1 | awk '{ print $3 }'`

if [ "$tapeday" = "$today" ]
then
 /bin/backup "$*"
 exit 0
else
 echo "$tapeday tape is in drive at $systemid" | mail $admmail
 echo "Please put $today tape in drive and type /bin/backup $*" | mail $onsite
 exit 1
fi
--
< Alan H. Mintz             | Voice +1 714 980 1034 >
< Micro-Quick Systems, Inc. | FAX   +1 714 944 3995 >
< 10384 Hillside Road       | ...!uunet!mq!alan     >
< Alta Loma, CA  91701 USA  | alan at MQ.COM           >

======================================================================
-- 
--------------------- He who laughs last laughs last ---------------------
Hendrik Vermooten, ZEUS software    TEL +27 12 64-5507, FAX +27 12 64-8382
Bang: ..!uunet!ddsw1!olsa99!zeusa!hendrik     or        hendrik at zeusa.UUCP
----------------- He whose laugh lasts longest laughs last ---------------



More information about the Comp.unix.admin mailing list