[2396] in Athena Bugs

home help back first fref pref prev next nref lref last post

Re: /etc/athena/backup

daemon@ATHENA.MIT.EDU (dkk@ATHENA.MIT.EDU)
Thu Jun 15 19:23:18 1989

From: <dkk@ATHENA.MIT.EDU>
Date: Thu, 15 Jun 89 19:22:51 EDT
To: Richard Basch <probe@ATHENA.MIT.EDU>
Cc: bugs@ATHENA.MIT.EDU, operator@ATHENA.MIT.EDU

#!/bin/sh -x
#
# Title:	Athena LAN Backup Procedure
# Author:	Michael R. Gretzinger, Phil Hammar
# Creation Date: 30-Apr-1984
# Last Modified: 19-Nov-1987
#
# Description:
#
# This shell script performs filesystem dumps across a local area network
# (LAN)to structures on a local server.  It runs nightly via cron.  Three 
# classes of hosts are defined: SERVER_HOSTS, DEVELOPMENT_HOSTS, and 
# CLIENT_HOSTS.  The filesystems dumped are determined by the host class.  
# Every day one machine in the LAN gets a zero level dump in the order 
# determined by the file /u1/hosts.
#
# Dump file name format:
#	<hostname>.<structure>.<level-code>
#
# Required Files:
#	/backup/hosts:		Contains a list of hosts (one host per line)
#				that this server is responsible for
#	/backup/server_hosts:	Contains list of server hosts
#	/backup/development_hosts: Contains list of development hosts
#	/etc/athena/backuperr:	Shell script to log backup errors
#
# Required Directories:
#	/u2/weekly:		Weekly incrementals and full dumps are placed
#				here
#	/backup/log		Logfiles for each dump are placed her
#
# Ownership and Protection Assuptions:
#	The backup account must exist on every machine and must be a member
#	of the "operator" group.  On machines that do not trust servers, the
#	file ~backup/.rhosts must exist and contain entries of the form
#	"<server-name> backup" (angle brackets not included).
#	It is assumed that the following files have group ownership of
#	"operator" and group read/write access:
#		/dev/*ra*
#		/etc
#--

BINDIR=/etc/athena
LOGDIR=/backup/log
WEEKLY_STRUCT=u2
WEEKLY_DIR=/$WEEKLY_STRUCT/weekly
STATUS_FILE=/usr/adm/backup.status
SERVER=`hostname`
HOSTS=`cat /backup/hosts`
SERVER_HOSTS=`cat /backup/server_hosts`
DEVELOPMENT_HOSTS=`cat /backup/development_hosts`
CLIENT_STRUCTURES="mit u1"
SERVER_STRUCTURES="mit"
DEVELOPMENT_STRUCTURES="mit source"
setnextweek=0
incrlevel=0
nextweek=""
w_outofspace=0
d_outofspace=0

#
# Determine amount of space available on backup filesystems
#
wavail=`df | awk "/$WEEKLY_STRUCT/ {print \\$4}"`
wavail=`expr $wavail \* 1024`
if [ $wavail = 0 ]
then
    $BINDIR/backuperr $SERVER "" "" "" \
     "/$WEEKLY_STRUCT out of space; weekly incrementals will not be performed."
    exit
fi

# Read in backup status variables: 'weekly_host' and 'weekly_level'
eval `cat $STATUS_FILE`

for i in $HOSTS
do
#
# Determine dump level and target directory
#
    if [ $i = "$weekly_host" ]
    then
	setnextweek=1
	target_dir=$WEEKLY_DIR
	if [ $weekly_level = 0 ]
	then
	    level=0
	else
	    level=5
	fi
#
# Determine structures to be dumped
#
    if [ `echo $DEVELOPMENT_HOSTS | grep -c $i` = 1 ]
    then
	structures=$DEVELOPMENT_STRUCTURES
	host=$i
    elif [ `echo $SERVER_HOSTS | grep -c $i` = 1 ]
    then
	structures=$SERVER_STRUCTURES
	host=$i
#
# Insert elif ... then statements here for any exceptions
#
    else
	structures=$CLIENT_STRUCTURES
	host=$i	
    fi
#
# Loop through structures and perform dump
#
    for j in $structures
    do
#
# Make abbrev for target filename
#
	target_name=$target_dir/$host.$j.$weekly_level

#
# Determine name of structure to be dumped
#
	if [ $j = root ]
	then
	    struct=/
	else
	    struct=/$j
	fi
#
# Perform the dump
#
# Conditional added by marcus 30.XI.88 because hosts tend to
#  hang on rsh to self.
#
	if [ $SERVER = $host ]
	then

          /etc/dump ${level}uf - $struct < /dev/null \
                1> $target_name 2> $LOGDIR/$host.$j.$level.log
	else

	  /usr/ucb/rsh $host /etc/dump ${level}uf - $struct < /dev/null \
		1> $target_name 2> $LOGDIR/$host.$j.$level.log
	fi

	case $? in
	0)	echo "Dump successful"
		;;
	1)
		$BINDIR/backuperr $SERVER $host $struct $level \
		    "Dump: error on startup.  See log file"
		;;
	3)
		$BINDIR/backuperr $SERVER $host $struct $level \
		    "Dump aborted abnormally; see log file"
		;;
	*)
		$BINDIR/backuperr $SERVER $host $struct $level \
		    "Unknown error in dump; see log file"
		;;
	esac

#
# Determine size of dump file; then complain if no more space on filesystem
#
	fs=`ls -l $target_name | awk '{print $4}'`
	wavail=`expr $wavail - $fs`
	    if [ $wavail -le 0 ]
	    then
		w_outofspace=1
	    fi
	if [ $w_outofspace = 1 ]
	then
	    $BINDIR/backuperr $SERVER $host $struct $level \
		"Filesystem out of space"
	    exit
	fi
    done
    else
	if [ $setnextweek = 1 ]
	then
	    setnextweek=0
	    nextweek=$i
	fi
    fi

done
#
# Update status file.
# If 'setnextweek' is set then 'weekly_level' should be incremented and
# 'weekly_host' reset to the first host in 'HOSTS'.
#
if [ $setnextweek = 1 ]
then
    weekly_host=`/usr/ucb/head -1 /backup/hosts`
#
#	These next three lines are no longer necessary since we now do
#	only level 0 backups.  -Phil Hammar 11/16/87
#
#   weekly_level=`expr $weekly_level + 1`  
#   if [ $weekly_level = 4 ]
#   then
    weekly_level=0
#   fi
else
    weekly_host=$nextweek
fi
cat > $STATUS_FILE <<EOF
weekly_host=$weekly_host
weekly_level=$weekly_level
EOF
exit
#
# 	$Source: /source/4.3/etc.athena/RCS/backup.sh,v $
#	$Author: dgg $
#	$Locker:  $
#	$Header: backup.sh,v 1.2 84/12/12 15:05:07 dgg Exp $
#

home help back first fref pref prev next nref lref last post