[comp.sys.encore] tape dump problem

cyrus@hi.UUCP (Tait Cyrus) (11/25/87)

I am having some problems with dumps on our Encore.  What I am trying
to do is put multiple level 1 dumps on the same tape.   The way I
do this is by first rewinding the tape, writing the 1st dump, rewinding
the tape, mt -f /dev/rmt20 fsf 1 (skipping over the first dump using
the no_rewind device), writing the 2nd dump, rewinding the tape, etc.....

I can restore the 1st dump ok, but trying to restore any of the others gives
me the following error:

	# mt rew
	# mt -f /dev/rmt20 fsf 1
	# restore iv 
	Verify tape and initialize maps
	Dump   date: Wed Nov 25 09:02:36 1987
	Dumped from: Thu Nov 19 12:57:03 1987
	Cannot find file dump list
	# 

Any ideas?  I would prefer if I could get this to work instead of having
to use 1 tape per dump (I am aware that I CAN'T put multiple level 0
dumps on the same tape -- my level 1 dumps are relatively small, though,
so all of my level 1 dumps WILL fit on one tape).

Thanks in advance,

-- 
    @__________@    W. Tait Cyrus   (505) 277-0806
   /|         /|    University of New Mexico
  / |        / |    Dept of EECE - Hypercube Project
 @__|_______@  |    Albuquerque, New Mexico 87131
 |  |       |  |
 |  |  hc   |  |    e-mail:
 |  @.......|..@       cyrus@hc.dspo.gov or
 | /        | /        seismo!unmvax!hi!cyrus
 @/_________@/

amos@taux01.UUCP (Amos Shapir) (11/26/87)

This is a problem common to many (most?) unix systems: 'restore' rewinds
the tape after reading the volume number from the terminal. The only solution
I have found is to run 'restore' up to the point it asks for the volume number,
then suspend it (or go to another terminal) and do the 'mt fsf' or the
appropriate 'dd' to position the tape at the correct file, and only then
continue with 'restore'.
-- 
	Amos Shapir			(My other cpu is a NS32532)
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel  Tel. +972 52 522261
amos%taux01@nsc.com (used to be amos%nsta@nsc.com) 34 48 E / 32 10 N

mikec@encore.UUCP (Mike Callahan) (12/01/87)

How to do multiple dumps per tape using undocumented BSD4.2 restore flags:
(At the end a sample dump script from the University of Oklahoma to do
all the typing for you)

First you must dump multiple file systems to tape:

        (level one dump, 6250 density, 2400 foot reel, /dev/rmt20 is the
         norewind device (Multimax specific), and update /etc/dumpdates)

        # dump 1udsf 6250 2400 /dev/rmt20 /dev/root
        # dump 1udsf 6250 2400 /dev/rmt20 /dev/backuproot
        # dump 1udsf 6250 2400 /dev/rmt20 /dev/usr

Using the norewind device removes all the work with "mt".
Now that the dump is done,  How to use restore:

        # restore -ivs 2

The "s" flag is undocument on BSD 4.2, but I believe it is in the BSD 4.3
documentation.  The number "2" provided signals the second file on the tape,
unlike "mt" which would skip two files.

NOTE:  using this method has the advantage of multiple files per tape, but
        dump will not detect end of tape.  If you reach the end of the reel
        you will have to redo the current dump (It helps to add up those
        percentages).

---------------------------------------------------------------------------
The following script is used at the University of Oklahoma to do the backup.
You will of course have to modify it to do use a different incremental order.

It defaults to /dev/rmt20, 6250 density, 2400 foot reels.  The dump level
follows this pattern:

                        Week    S M T W R F S
                        1:                  0
                        2:          8   7   3
                        3:          6   5   2
                        4:          8   7   3
                        5:          6   5   0

This four week patter will repeat, any other day does a level "9".  OU chose
this pattern since it does level "0" about once a month, and no tape is reused
for at least two weeks (they store level 0 dumps).

To override the defaults use the dump flags:

        # backup 0f /dev/rmt16

This does a level "0" dump on /dev/rmt16 of all the file systems.

If no file systems are specified on the command line, backup looks in
/etc/fstab.  The forth field (first number field) specifies the order.
If there is a "0" in the field, the file system is skipped.  Other
numbers must be unique, backup will dump them in numerical order.

Sample fstab:
**************************
/dev/md0a:/:rw:1:1
/dev/md0c:/all0:xx:0:2
/dev/md0d:/header0:xx:0:2
/dev/md0e:/usr2:rw:4:2
/dev/md1a:/root-dpc:rw:2:2
/dev/md1b::sw:0:2
/dev/md1c:/all1:xx:0:2
/dev/md1d:/header1:xx:0:2
/dev/md1e:/usr:rw:3:2
/dev/md1f:/usr3:rw:5:2
/dev/md2b::sw:0:2
/dev/md2c:/all1:xx:0:2
/dev/md2d:/header1:xx:0:2
/dev/md2e:/tmp:rw:0:2
/dev/md2f:/usr4:rw:6:2
**************************

The dump order is "/ /root-dpc /usr /usr2 /usr3 /usr4".

The shell script will ask you to press return between each dump to
allow you to rewind and change tapes if needed.  If dump errors out,
it will ask if you want to redo the last dump.

Have fun:
------------------------------Cut Here-------------------------------
#!/bin/sh
#
# user interface to filesystem backups
#
PATH=/etc:/bin
density=6250
length=2400
drive=/dev/rmt20
level=-1
usage="Usage: $0 [0-9dsfw] [arg ...]"

trap " " 1 3 4 5 6 7 8 10 12 13 14 15
trap "echo 'really quit?'; read a; if test \"X\$a\" = \"Xy\"; then exit; fi" 2

# device that root resides on (i.e. rhp0a)
root=`sed -e '2,$d' -e 's/:.*//' -e 's/\/dev\//r/' /etc/fstab`

#
# look over the flags supplied, if we find one we don't understand, DON'T
#       TAKE CHANCES, exit now
#
if test $# -gt 0; then
        key=$1
        shift
fi

for option in `echo $key | sed -e 's/[^ ]/& /g'`
do
        case $option in
                [0-9])  if test "$level" = "-1"; then
                                level=$option
                        else    # don't want to set the level more than once
                                echo $usage
                                exit 1
                        fi
                        ;;

                d)      if test "$1"; then
                                density=$1
                                shift
                        else
                                echo $usage
                                exit 1
                        fi
                        ;;

                s)      if test "$1"; then
                                length=$1
                                shift
                        else
                                echo $usage
                                exit 1
                        fi
                        ;;

                f)      if test "$1"; then
                                drive=$1
                                shift
                        else
                                echo $usage
                                exit 1
                        fi
                        ;;

                w)      noaction=1
                        ;;

                *)      echo $usage
                        exit 1
                        ;;
        esac
done

#
# if no level selected, let's figure one out.  This is very specific for
#       our dump scheme, whose cycle is:  0 8 7 3 6 5 2 8 7 3 6 5 0
#
if test "$level" = "-1" -o "$noaction"; then
        set `date`
        if test "$1" = "Tue"; then
                set 8 6 8
        elif test "$1" = "Thu"; then
                set 7 5 7
        elif test "$1" = "Sat" -o "$1" = "Sun"; then
                set 3 2 0
        else    # an off day (Mon Wed or Fri) probably want level 9
                set 9 9 9
        fi

        level=`awk '
                BEGIN { 
                        level[1] = '$1'; level[2] = '$2'; level[3] = '$3'; 
                        y["Jan"] = 1;  y["Feb"] = 2;  y["Mar"] = 3; 
                        y["Apr"] = 4;  y["May"] = 5;  y["Jun"] = 6; 
                        y["Jul"] = 7;  y["Aug"] = 8;  y["Sep"] = 9; 
                        y["Oct"] = 10; y["Nov"] = 11; y["Dec"] = 12; 
                } 
                /'$root'/ { 
                        if ($2 == 0) { 
                                dates[0] = sprintf("%d%02d%02d", $7, y[$4], $5);
                        } 
                        if ($2 == level[1]) { 
                                dates[1] = sprintf("%d%02d%02d", $7, y[$4], $5);
                        } 
                        if ($2 == level[2]) { 
                                dates[2] = sprintf("%d%02d%02d", $7, y[$4], $5);
                        } 
                        if ($2 == level[3]) { 
                                dates[3] = sprintf("%d%02d%02d", $7, y[$4], $5);
                        } 
                } 
                END { 
                        if (dates[1] < dates[0])
                                level[0] = level[1];
                        else if (dates[1] < dates[2])
                                level[0] = level[1];
                        else if (dates[2] < dates[3])
                                level[0] = level[2];
                        else
                                level[0] = level[3];

                        print level[0]
        }' < /etc/dumpdates`
fi

#
# let's figure out the filesystems to dump and in what order
#
filesystems=`awk -F: '
                {       if ($4 != 0 && order[$4] != "")
                                error = 1;
                        else {
                                order[$4] = $2;
                                if ($4 > max)
                                        max = $4;
                        }
                }
                END {
                        for (i = 1; i <= max; ++i)
                                printf("    %s", order[i]);

                        exit error;
                }
        ' < /etc/fstab`

#
# this is for the 'w' option, exit afterwards
#
if test "$noaction"; then
        echo "File Systems to be backed up:"
        for i in $filesystems
        do
                dev=`awk -F: '{ if ('\"$i\"' == $2) print $1}' < /etc/fstab`
                dev=`echo $dev | sed -e 's/\/dev\//\/dev\/r/'`
                echo "$dev      ($i)    This dump: Level $level"
        done
        exit 0
fi

#
# tell operator what options we decided on
#
echo -n "Dump level: $level    Density: $density    Tape Size: $length"
echo "    Drive: $drive"
echo
echo Dumping filesystems in this order:
echo
echo "$filesystems"

#
# Now we finally get around to actually dumping the filesystems
#
for i in $filesystems
do
        dev=`awk -F: '{ if ('\"$i\"' == $2) print $1}' < /etc/fstab`
        dev=`echo $dev | sed -e 's/\/dev\//\/dev\/r/'`

        again=1
        while test $again -eq 1; do
                echo
                echo "  Dumping $dev ( $i )"
                echo
                echo "Change tapes if desired. Type return when drive is ready."
                read dummy
                if test "$dummy" = "stop"; then
                        echo
                        echo Aborting backup program.
                        echo
                        exit 1
                elif test "$dummy" = "skip"; then
                        echo
                        echo Skipping $i
                        again=0
                else
                        echo "# dump ${level}udsf $density $length $drive $dev"
                        dump ${level}nudsf $density $length $drive $dev | awk '
                                BEGIN {
                                        len = 0
                                }
                                /DUMP: DUMP:/ {
                                        len=($3*1024/'$density')+($3*0.3/10)/12
                                }
                                { print }
                                END {
                                        if (len == 0)
                                                exit 0
                                        printf("  DUMP: used %d feet\n", len);
                                        exit 1
                                }'
                        if test $? -ne 0; then
                                sync
                                echo "Do you want to restart? (y/n): "
                                read dummy
                                if test "$dummy" = "y"; then
                                        echo "You may want to mount a new tape."
                                else
                                        again=0
                                fi
                        else
                                sync
                                again=0
                        fi
                fi
        done
done
mt -t $drive offl
echo
echo "Backup program complete."
-------------------------------------------------------------------------

An important note about dump:  Doing dump single user or on an unmounted
file system is best (assuming file system has fsck'ed ok).  Dump has
been known to not produce a good backup when running on a mounted file
system.


Have fun with this.

        Mike Callahan
        mikec@encore
        mikec@multimax.arpa


IMPORTANT MESSAGE:

The above information and program is subject to change without notice
and should not be construed as a commitment by Encore Computer
Corporation.  Encore Computer Corporation assumes no responsibility
for any errors that may appear in the above.