[Next] [Previous] [Up] [Top] [Contents]

16.3 Backup and Restore Commands

16.3.2 Sample backup scripts

You can write a script to do the periodic backups, requiring operator intervention, e.g.:

# Script to do a complete backup of the system
# A dataless system to a tape drive on a server.
echo "***************************************************************"
echo "This program will allow you to backup GALLIFREY onto magtape"
echo " Follow the directions given below."
echo "***************************************************************"
echo "Mount tape for partition a and g"
echo " then type RETURN "
read start
echo " ...working - Starting GALLIFREY backup "
/usr/etc/dump 0ufsdb server:/dev/nrst8 6000 54000 126 /dev/sd0a && echo "Done with partition a ..."
/usr/etc/dump 0ufsdb server:/dev/rst8 6000 54000 126 /dev/sd0g && echo "Done with partition g ..."

/usr/bin/mt -f /dev/rst8 rewoffl

Backup scripts similar to this can be run by you as root, or by an operator. You may wish to set up a login in /etc/passwd similar to:

backup:ogHt5C0Z.bcD2:20:5:Remote Backup to Server:/etc/adm:/etc/adm/backup

where the backup script is the shell, /etc/adm/backup. You or the operator would login as backup and the program would run at login. When the program terminates you would be logged out.

You can also set up your backup script to be run by cron. If the tape is large enough to hold the entire backup the following script could be set to run periodically. You will just need to make sure that the proper tapes are in the drive at the appropriate times.

#!/bin/sh
# Cron script to do a complete backup of the system
#/dev/sd0a 15663 6335 7762 45% /
#/dev/sd0g 138511 101061 23599 81% /usr
#/dev/sd2h 268319 4208 237280 2% /home
#/dev/sd2f 458671 36844 375960 9% /usr/local
#/dev/sd2a 47711 297 42643 1% /var
HOST='hostname'
admin=frank
Mt=/bin/mt
Dump=/usr/etc/dump
device=/dev/nrst0
size=6000
dens=54000
blksz=126
# Failure - exit
failure () {
/usr/ucb/mail -s "Backup Failure - $HOST" $admin << EOF
$HOST
Cron backup script failed. Apparently there was no tape in the device.
EOF
exit 1
}
# Dump Failure - exit
dumpfail () {
/usr/ucb/mail -s "Backup Failure - $HOST" $admin << EOF
$HOST
Cron backup script failed. Could not write to the tape.
EOF
exit 1
}
# Success
success () {
/usr/ucb/mail -s "Backup completed successfully - $HOST" $admin << EOF
$HOST
Cron backup script was apparently successful. The /etc/dumpdates file is:
'/bin/cat /etc/dumpdates'
EOF
}
# Confirm that the tape is in the device
$Mt -f $device rewind || failure
$Dump 0ufsdb $device $size $dens $blksz /dev/sd0a || dumpfail
$Dump 0ufsdb $device $size $dens $blksz /dev/sd0g || dumpfail
$Dump 0ufsdb $device $size $dens $blksz /dev/sd2h || dumpfail
$Dump 0ufsdb $device $size $dens $blksz /dev/sd2f || dumpfail
($Dump 0ufsdb $device $size $dens $blksz /dev/sd2a || dumpfail) && success
$Mt -f $device rewoffl


Unix System Administration - 8 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]