------------------------------- Page    i -------------------------------

                   UTS Tape Backup and Restore System




                                                 February 16, 1981

------------------------------- Page   ii -------------------------------

                            TABLE OF CONTENTS


1.    Introduction  . . . . . . . . . . . . . . . . . . . . . . . . .   1

2.    Programs  . . . . . . . . . . . . . . . . . . . . . . . . . . .   1

3.    System Overview.  . . . . . . . . . . . . . . . . . . . . . . .   1

4.    Example . . . . . . . . . . . . . . . . . . . . . . . . . . . .   2

4.1      Backup . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
4.2      Restore  . . . . . . . . . . . . . . . . . . . . . . . . . .   3


                                                            Last Page   3

-------------------------------- Page  1 --------------------------------

1.    INTRODUCTION

Since data  stored on  disk sometimes  gets lost  due to  user or  system
error, it is a good  idea to have a way of restoring files from a  backup
copy.  The  UTS tape  backup  and restore  system provides  a  mechanism,
entirely contained within UTS, for doing this.




2.    PROGRAMS

Following  are  brief  descriptions  of  the  programs  involved  in  the
backup/restore system.  In  each case,  more detail can  be found in  the
manual page for the  command, which may  be viewed on-line  by "man  com-
mand".

cron   The cron program automatically invokes programs at times specified
       in the file /usr/lib/crontab.

label  The label program writes OS standard labels on magnetic tape.

stofs  The stofs program stores file systems on tape using the fast  disk
       driver for efficiency.  A file system is the data on one minidisk.

restfs The restfs program restores a file system that has been backed  up
       to tape by stofs.

tape   The tape command requests the  operator to mount a magnetic  tape,
       and after the tape  is mounted, tape  can run a specified  command
       (e.g. stofs).




3.    SYSTEM OVERVIEW.

This section  will  describe the  operation  of the  system  by  stepping
through the sequence of programs as they would run in order.

The backup process  is initiated,  usually every  night, by  an entry  in
crontab.  The desired sequence is to mount the tape, check  the label (to
be sure the operator mounted the right tape), then run the stofs  program
to put the data on  the tape.  This is done by invoking the tape  program
with an argument specifying the label and stofs programs to be run.   The
output of these programs is saved in a file which  must be checked in the

-------------------------------- Page  2 --------------------------------

morning to be sure that everything ran ok.

The way to restore a file is to determine when it was last backed up, and
use restfs  to restore  the  file system  the file  is  on.  Restfs  will
restore the entire file system.  This is usually done to a spare minidisk
reserved for this purpose.  When  the restfs is done, the file system  is
mounted, then the desired file is  copied into the user's directory,  and
finally the restored file system is unmounted.




4.    EXAMPLE

Among other details, it turns out that there is  too much data to fit  on
one tape.  In the following  example, we will assume that the use of  two
tapes will suffice, and we will trace through the process for tape number
1.


4.1      BACKUP

To get the process started, we need an entry in crontab.  This might have
the form:

   0 21 * * 1-5 backup /usr/backup/backup 1
   0 21 * * 1-5 backup /usr/backup/backup 2

The first line tells crontab that at 0 minutes past 9 PM (21), regardless
of month (*) or  year (*), but only  on Monday through Friday (1-5),  run
the command "/usr/backup/backup 1" under the "backup" id.

The command  /usr/backup/backup is  a  shell file  with one  argument,  a
number which distinguishes between  the two tapes.   The contents of  the
shell file are:

   a='cat /usr/backup/tape$1'
   tape -m -w -d 6250 -c "(label $a; \
   /etc/stofs -f /etc/backlist$1 $a) 2> /usr/backup/out$1 $a

If this shellfile is invoked with the argument "1", then the shell  vari-
able $1 will contain  "1".  In this case,  the first line reads the  file
/usr/backup/tape1 and stores the result  in the shell variable $a.   This
file should be changed each  day to contain a new tape id.  The next  two
lines invoke  the tape  command with  the mount  option (-m),  the  write
option (-w), which  requests a  write ring, density  6250 (-d 6250),  the
command option (-c "..."), which tells tape to execute the given  command
when the tape is mounted, and finally the tape id ($a).

-------------------------------- Page  3 --------------------------------

The command is actually  a sequence  of two commands  grouped within  the
parentheses, with their output (and standard error (2>)) redirected  into
the file  /usr/backup/out1.  The  commands are  label, which  labels  the
tape, and  stofs,  which  saves  the  file systems  listed  in  the  file
/etc/backlist1 onto the tape $a (read from /usr/backup/tape1).


4.2      RESTORE

Let us assume that the file  /usr/src/cmd/blah.c has been lost and  needs
to be restored.  The first thing to do is to  find out the tape id of the
tape used to back up the /usr/src file system most recently.  Presumably,
the tapes used for backup have been recorded somewhere, so this shouldn't
be too hard.  When we get it, we will issue the command:

   tape -m tapeid

to get the tape mounted.  After a  suitable delay, the tape command  will
send us a message  that the tape is  mounted.  Assuming that disk 440  is
available for restoring, we will then issue:

   /etc/restfs tapeid /usr/src /dev/fdsk440

When this is done, we will mount the file system by saying

   /etc/mount /dev/dsk440 /fetch

(you have to be superuser to do this).  The choice of /fetch to mount  it
is arbitrary; any directory will do.  At this point we  would restore the
file by the command

   cp /fetch/cmd/blah.c /usr/src/cmd/blah.c

and then unmount the file system and detach the tape by

   /etc/umount /dev/dsk7
   tape -u tapeid

and we are done.

-------------------------------- The End --------------------------------
