COHERENT manpages

This page displays the COHERENT manpage for backups [Strategies for backing up COHERENT].

List of available manpages
Index


backups -- Technical Information

Strategies for backing up COHERENT

This entry  describes how to  backup files --  that is, how to  copy one or
more selected  files onto  floppy disks.  You  should do this  regularly to
provide yourself  with a  spare copy of  valuable files should  your system
suffer a catastrophe.

The strategy  you adopt for backups  will vary quite a  bit, depending upon
the  medium onto  which you  back  up your  files: tapes  or floppy  disks.
Floppy disks  are inexpensive,  but their  limited capacity means  that you
have to  plan carefully.  Tapes are  simpler to use than  floppy disks, but
are more  expensive.  The following sections  describe first the strategies
for backing up onto floppy disks; and then for backing up onto tapes.

Backing up Onto Floppy Disks

There are two general strategies for backing up files onto floppy disks:

-> Use the command tar to create  archives of files on a floppy disk.  This
   is fine for archiving a limited set of files on an irregular basis.

-> The other  strategy uses  the command gnucpio  to implement a  system of
   regular dumps.  This strategy  is preferred for systems that daily amass
   data of importance  for a real-world job, such as  running a business or
   managing a research project.

You  should always  have a  procedure  of backups  for your  system.  Which
strategy you use  depends on how you are using  your system.  The following
sections describe  how to  implement each  strategy of backups.   Note that
COHERENT  includes a  version of  the  UNIX utility  dump for  the sake  of
compatibility with  older versions of  UNIX and COHERENT;  however, dump is
obsolete, should not be used, and will not be described here.

Please note  that the  following descriptions assume  that you are  using a
5.25-inch, high-density floppy disks set in  drive 0 (drive A).  For a list
of available floppy-disk devices, see the Lexicon entry for floppy disks.

The following describes how to use tar to back up onto floppy disks.

The first step is to prepare floppy disks to receive files.  Insert a 5.25-
inch floppy disk into drive 0, and then type the following command:

    /etc/fdformat -v /dev/rfha0

The  command fdformat  formats  the floppy  disk, verifying  that no  media
defects  exist.  You  must perform  this task of  formatting a  floppy disk
before you use it the first time.

The next  step is to  create an archive of  the files you wish  to back up.
Use the  portable archive command  tar to collect  a mass of  files into an
archive  on  the  floppy disks.   For  example,  to  archive  all files  in
directory source, use the following command:

    tar cvf /dev/rfha0 source

The options  cvf tell tar  to create an  archive, run in  verbose mode, and
write  the archive  onto the  device  or into  the file  named in  the next
argument.  /dev/rfha0 names the floppy  device onto which you wish to write
the archive.  Finally, source is the directory whose files you wish to back
up.

To perform a listing of the contents of the newly created archive, type

    tar tvf /dev/rfha0

The  options tvf  tell tar  to  list the  contents of  the archive,  run in
verbose mode,  and read the  archive from the  device or file  named in the
next argument.

To extract several files from the archive, enter a command of the form

    tar xvf /dev/rfha0 source/myfile 'source/*.c'

The options xvf  tell tar to extract or unarchive  the specified files, run
in verbose mode, and read the  archive from the device or file named in the
next argument.  Note that  the second file argument contains a ``wildcard''
character and thus must be quoted to prevent expansion by the shell.

For more information on how to use tar, see its entry in the Lexicon.

The following describes how to back up using gnucpio.

The  COHERENT utility  gnucpio performs  mass dumps  and restores  of files
using a universally recognized file format.

In  this example,  dumps  are performed  monthly, weekly,  and daily.   You
should prepare at  least three sets of floppy disks  for the monthly saves,
giving you three  months of full backup.  You will  use the floppy disks in
rotation, with the oldest always used next.

Once a month, you should dump the entire system.

Once a week,  you should dump information in the  system that is new or has
been changed since  the end of the previous week.   You will need five sets
of floppy disks, because some months have five weekends in them.

Finally, every  day you should save information that  has changed that day.
For these  dumps, you  will need  five sets of  floppy disks: one  for each
working day.  You may need extras in case of weekend work.

Label each set of disks carefully  as monthly, weekly, or daily.  Label the
daily floppy  disks ``Monday'' through ``Friday'',  the weekly floppy disks
``Week 1''  through ``Week  5'', and the  monthly floppy disks  ``Month 1''
through ``Month  3''.  When  you perform  the dump, write  the date  on the
label.

The following  gives a  step-by-step description of  how to use  gnucpio to
back up  files.  The next samples  are given with the  suggestion that your
system has only one 5.25-inch floppy-disk drive.

1. Log into the system as the superuser root.

2. If you have not yet done so, use the command fdformat to format a set of
   floppy  disks,  as shown  above.   With  high-density, 5.25-inch  floppy
   disks, a rule  of thumb is to prepare one  floppy disk for each megabyte
   of data to be dumped.

3. If  other users  are logged  into the  system, use  the command  wall to
   request that they log off.  For example:

       /etc/wall
       Please log off.
       Time for file dump.
       <ctrl-D>

4. Be sure that all users are logged off the system by typing the command:

       who

   This command names all users who are still on the system.

   If they  have not  logged off  in a few  minutes, send  another message.
   Repeat the process until who shows no users except yourself.

5. When all  other users have  logged off, execute the  command shutdown as
   described in its Lexicon entry.

6. Run the script  mount.all to mount all of your  file systems.  Then, run
   the COHERENT command fsck on each file system to check its integrity.

7. If this  is the last  workday of the  month, perform a  monthly dump, to
   back  up the  entire system.   Insert  the first  volume of  the correct
   monthly dump  floppy disk  into the  floppy drive, after  adding today's
   date to the label, and type the commands:

       cd /
       find . -print | gnucpio -ocF /dev/rfha0

   Option  -F tells  gnucpio to  write everything  to the  raw, 2400-block,
   floppy-disk device /dev/rfha0.

   Note that if  you want to split your dump  across different media (i.e.,
   write the first volume onto tape and the second onto a floppy disk), you
   should  not use  the option  -F; gnucpio  will write  its output  to the
   standard output,  and you can use the shell  operator `>' to redirect
   that to  the device /dev/rfha0. If  you do not use  -F, gnucpio will ask
   you, after it finishes writing a volume, for the name of the device into
   which it should redirect the next volume of output.

   As more  floppies are needed, gnucpio  will ask you to  insert them.  Be
   sure to label each floppy disk with its volume number.

8. If this  is the last work  day of the week, but not  the last workday of
   the  month, perform  a  weekly dump.   Prepare the  correct weekly  dump
   floppy disks,  add today's  date to the  label, insert the  first floppy
   disk, and type the command:

       cd /
       find . -newer cpio.weekly -print | gnucpio -ocF /dev/rfha0
       touch cpio.weekly

   This will dump all files that are younger than file cpios.weekly.

9. If this is neither the last workday of the month nor the last workday of
   the week, you will perform a  daily dump.  Prepare the daily dump floppy
   disk with today's day of the week, add today's date to the label, insert
   the first floppy disk into the drive, and type the command:

       cd /
       find . -newer cpio.daily -print | gnucpio -ocF /dev/rfha0
       touch cpio.daily

   This will dump files that are younger than file cpio.daily.

10.
   Type sync to ensure that all buffers are flushed.

11.
   When  you are  finished dumping  data, type  the command  /etc/reboot to
   return your system to multi-user mode.

For more information  on how to use gnucpio and  find, see their respective
entries in the Lexicon.

If you wish,  you can back up only limited  portions of your system.  To do
so, just  name in your  find command the  directories you wish  to back up.
For example, to back up everything  in your home directory and in /usr/lib,
use the following command:

    find $HOME /usr/lib -type f -newer cpio.daily -print | gnucpio -ocF /dev/rfha0
    touch cpio.daily

When you determine the backup strategy you wish to use, you should save the
appropriate  commands  into  a  script,  to  ensure that  backups  are  run
correctly every time.

The following describes how to restore files from floppy disks.

If you find  that a file has been inadvertently  destroyed, you can restore
the information to disk from backup floppy disks.

To restore  information from backups created with gnucpio  or tar, you must
first determine the date and time that the file was last known to have been
modified.  From  this date, determine  on which set  of disks the  file was
last  correctly dumped.   Find the  set of floppy  disks labeled  with that
date, and insert into the floppy-disk  drive the first one in the set.  For
example, if  you wish to restore  the file myfile, from  a gnucpio archive,
use the command:

    gnucpio -icdvF /dev/rfha0 myfile

To retrieve myfile from a tar archive, use the command:

    tar xvf /dev/rfha0 myfile

Both of  these commands assume  that the disks  are high-density, 5.25-inch
floppies in drive  0 (drive A).  See the Lexicon  article floppy disk for a
table that  shows which COHERENT  device is associated with  which size and
density of  disk, and which disk  drive.  You may have  to insert more than
one disk from the set of backups until you find the one that holds the file
you want.

Backing up Onto Tapes

The strategy for backing up onto tape resembles that for floppy disks, with
the exception  that in many  instances the tape  medium is larger  than the
device being  backed up.   This makes  it worth your  while to back  up the
entire device every time you do  a back up, rather than perform incremental
backups.  The  reason for this  is simple: the  fewer tapes over  which you
have spread your backups, the lower the risk that one will fail.

To back up an entire partition, do the following:

1. Pop a tape  into your tape device.  Make sure  the tape is appropriately
   labeled.

2. Log in as the superuser root, and type the following command:

       /etc/shutdown single 0

   This returns your system to single-user mode immediately.

3. Use the command gtar to back up your partition, as follows:

       gtar -cvzf /dev/tape directory

   tape identifies  the tape device onto which the  backup will be written,
   and directory identifies the file  system to back up.  For example, tape
   device /dev/rStp2 is  a SCSI tape device that has  SCSI identifier 2 and
   performs autorewinding.  For a  list of recognized tape devices, see the
   article for tape. in the Lexicon.

   Please note  two points about directory. First, do  not use the absolute
   path name when specifying a directory:  that is, use usr, not /usr. gtar
   strips  the leading  `/'  in any  event,  but it's  always  best to  use
   relative path names whenever possible.  Second, in single-user mode only
   the  root file  system is  mounted  by default;  therefore, if  the file
   system you wish to back up  resides on its own partition, you must mount
   that file system by hand before you begin to back it up.

   Note that  the z option  to the gtar  command tells gtar to  use gzip to
   compress  the files  automatically.  File  compression  is a  good idea:
   because fewer  bits are being  written to the  tape, the backup  will go
   faster; and  because less tape  is used, the  risk of a  tape failure is
   lessened.

3. When gtar has finished writing to the tape, wait until the tape finishes
   rewinding; then  remove it  from its  drive and put  it in a  safe place
   (i.e.,  away from  magnets and children).   Then type  <ctrl-D> to
   return your system to multi-user mode.

That's all there  is to it.  To restore information  from the tape, put the
tape into  the drive and use  the gtar command to fetch  the file you want.
For example,  to restore file  /v/fwb/myfile.c from a SCSI  tape drive that
has SCSI identifier 2, use the following command:

    gtar -xvzf /dev/rStp2 "v/fwb/myfile.c"

Note that  the file  will be  written into a  subdirectory of  your current
directory.  For example, if your current directory is /v/fwb, then myfile.c
will be restored into a file with the path name /v/fwb/v/fwb/myfile.c. This
may be a  little inconvenient, but is not nearly  as inconvenient as having
to create myfile.c by hand.

An Example of Using Floppy Tape

This section  gives examples of how to  use QIC-40/QIC-80 (``floppy tape'')
to write archives to floppy tape, and read them back.  It uses the commands
tape, which  manipulates the tape  device; and gtar,  which writes archives
onto the physical tape, and reads them back.

Suppose you have  a directory named dir1, which contains  files you want to
backup.  To back up all files  in that directory onto a tape, insert a tape
cartridge into the drive, then type:

    gtar -cvf /dev/ft dir1

To verify that the contents of  the tape match the original files, run gtar
again in verification (``diff'') mode:

    gtar -df /dev/ft

We  strongly  urge  you to  verify  tapes  after  they  have been  written,
especially with  floppy-tape devices.  If a tape fails  this test, throw it
away and build  a new archive; otherwise, you may  receive a nasty surprise
when you try  to restore a file from that  tape.  Do not be surprised if an
otherwise sound tape fails after time:  a tape does wear out after a number
of uses.

To later extract the files from the tape, use

    gtar -xf /dev/ft

To  use data  compression,  the preceding  commands  can be  used with  the
addition of gtar's option -z, as follows:

    gtar -czvf /dev/ft dir1
    gtar -dzf /dev/ft
    gtar -xzf /dev/ft

To backup only selected files to tape, you could do the following:

    find dir -type f -print | sort > Files

then manually  edit the  file Files  so it contains  only the names  of the
files you want to back up.  Then use the command:

    gtar -cv -T Files -f /dev/ft

The previous examples used /dev/ft, the device node that calls for the tape
to be  rewound when the  device is closed.   This is convenient  if you are
putting only one archive onto  tape.  To concatenate multiple archives on a
single cartridge, use  the no-rewind-on-close device.  For example, suppose
you have a  second directory, dir2, and you want  to back it up on the same
tape, after an archive of dir1. The following commands accomplish this:

    gtar -cvf /dev/nft dir1
    gtar -cvf /dev/nft dir2

After each  archive is written, the  tape remains positioned at  the end of
the archive.  To verify the contents of both archives, do the following:

    # this command rewinds the tape:
    tape rewind
    # this command displays the contents of the first archive:
    gtar -tvf /dev/nft
    # this command displays the contents of the second archive:
    gtar -tvf /dev/nft

If you  make a note of  the locations of archives as  they are written, you
can retrieve them later without having to read the preceding archives.  For
example:

    # rewind the tape:
    tape rewind
    # write "dir1" archive at start of tape:
    gtar -cvf /dev/nft dir1
    # find current position of the tape:
    tape tell

The command tape tell returns a string of the form:

    Tape Is at Byte Offset 102400

Continuing:

    # write "dir2" archive after "dir1":
    gtar -cvf /dev/nft dir2
    # read the current position:
    tape tell

The second instance of tape tell returns a string of the form:

    Tape Is at Byte Offset 235520

That is, it  shows that the tape has advanced  after the second archive was
written onto it.  At this  point, the cartridge is removed, then reinserted
into the tape drive at a later date:

    tape seek 102400
    gtar -tvf /dev/tape

The command tape seek moves the tape to the byte position 102400, i.e., the
end of  the first archive.  This  command assumes that you  jotted down the
position displayed by the  command tape tell executed earlier.  The command
gtar then displays the contents of the second archive.

See Also

Administering COHERENT,
gnucpio,
gtar,
tape