
# This script will automatically save all information in ARCHIVE_SAVED onto
# magnetic media.  It will also position the tape to the correct location,
# before saving data.

# Change this to your magnetic media rewind device
REWIND=/dev/rmt1

# Change this to your magnetic media no rewind device
NOREWIND=/dev/rmt0

# The default location where system information ready for archive will
# kept
ARCHIVE_SAVED=/usr/adm/archive/saved

if [ -s $ARCHIVE_SAVED/files_on_tape ]
then
	echo "\nIs this tape new, or already contain several archive files ?"
	echo "(Y for new, anything else for contains archive files):  \c"
	read STATE

	if [ $STATE = 'Y' -o $STATE = 'y' ]
	then
		echo "1" > $ARCHIVE_SAVED/files_on_tape
		FILES=1
	else
		OLDFILES=`cat $ARCHIVE_SAVED/files_on_tape`
		FILES=`expr $OLDFILES + 1`
		echo $FILES > $ARCHIVE_SAVED/files_on_tape
	fi
else
	echo "1" > $ARCHIVE_SAVED/files_on_tape
	FILES=1
fi

# Positioning tape head
<$REWIND

while [ $FILES -gt 1 ]
do
	<$NOREWIND
	FILES=`expr $FILES - 1`
done

cd $ARCHIVE_SAVED
/bin/find . -print | /bin/cpio -oBv >$REWIND

echo "\nAll files in $ARCHIVE_SAVED have been saved onto magnetic media"
exit 0
