bbaacckkuuppss -- 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.

_B_a_c_k_i_n_g _u_p _O_n_t_o _F_l_o_p_p_y _D_i_s_k_s
There are two general strategies for backing up files onto floppy disks:

-> Use the command ttaarr 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  ccppiioo  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 system 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 the COHERENT
system  includes a  version  of the  UNIX  utility dduummpp,  for  the sake  of
compatibility with  older versions of  UNIX and COHERENT;  however, dduummpp is
obsolete 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 ffllooppppyy ddiisskkss.

The following describes how to use ttaarr 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 ffddffoorrmmaatt  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  ttaarr to collect  a mass of  files into an
archive  on  the  floppy disks.   For  example,  to  archive  all files  in
directory ssoouurrccee, use the following command:

    tar cvf /dev/rfha0 source

The options  ccvvff tell ttaarr  to create an  archive, run in  verbose mode, and
write  the archive  onto the  device  or into  the file  named in  the next
argument.  /ddeevv/rrffhhaa00 names the floppy  device onto which you wish to write
the archive.  Finally, ssoouurrccee 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 ttvvff  tell ttaarr  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 xxvvff  tell ttaarr 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 ttaarr, see its entry in the Lexicon.

The following describes how to back up using ccppiioo.

The COHERENT utility ccppiioo 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 _m_o_n_t_h_l_y, _w_e_e_k_l_y, or _d_a_i_l_y.  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 ccppiioo 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 rroooott.

2. If you have not yet done so, use the command ffddffoorrmmaatt 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  wwaallll 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 wwhhoo shows no users except yourself.

5. When all  other users have  logged off, execute the  command sshhuuttddoowwnn as
   described in its Lexicon entry.

6. Run the script  mmoouunntt.aallll to mount all of your  file systems.  Then, run
   the COHERENT command ffsscckk on each file system to check its integrity.

7. If this  is the last  workday of the  month, perform a  _m_o_n_t_h_l_y 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 | cpio -oc >/dev/rfha0

   This  will dump  everything to the  raw, 2400-block,  floppy-disk device
   /ddeevv/rrffhhaa00.  ccppiioo

   As more  floppies are needed, ccppiioo  will ask you to  insert them.  After
   you insert the floppy disk, you will have to type the device name, e.g.,
   /ddeevv/rrffhhaa00, at  ccppiioo's prompt.  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  _w_e_e_k_l_y 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 | cpio -oc >/dev/rfha0
       touch cpio.weekly

   This will dump all files that are younger than file ccppiioo.wweeeekkllyy.

9. If this is neither the last workday of the month nor the last workday of
   the week, you will perform a  _d_a_i_l_y 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 | cpio -oc >/dev/rfha0
       touch cpio.daily

   This will dump files that are younger than file ccppiioo.ddaaiillyy.

10.
   Type ssyynncc to ensure that all buffers are flushed.

11.
   When  you are  finished dumping  data, type  the command  /eettcc/rreebboooott to
   return your system to multi-user mode.

For more  information on  how to  use ccppiioo and  ffiinndd, 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  ffiinndd command the  directories you wish  to back up.
For example, to back up everything  in your home directory and in /uussrr/lliibb,
use the following command:

    find $HOME /usr/lib -type f -newer cpio.daily -print | cpio -oc >/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 ccppiioo  or ttaarr,  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 mmyyffiillee,  from a ccppiioo archive, use
the command:

    cpio -icdv myfile < /dev/rfha0

To retire mmyyffiillee from a ttaarr 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 ffllooppppyy ddiisskk 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.

_B_a_c_k_i_n_g _u_p _O_n_t_o _T_a_p_e_s
The strategy for backing up onto tape resemble those for floppy disks, with
the except 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1. Pop a tape  into your tape device.  Make sure  the tape is appropriately
   labeled.

22. Log in as the superuser rroooott, and type the following command:

       /etc/shutdown single 1

   This returns your system to single-user mode after one minute.

33. Use the command ggttaarr to back up your partition, as follows:

       gtar -cvzf /dev/_t_a_p_e _d_i_r_e_c_t_o_r_y

   _t_a_p_e identifies  the tape device onto which the  backup will be written,
   and _d_i_r_e_c_t_o_r_y identifies the file  system to back up.  For example, tape
   device /ddeevv/rrSSttpp22 is  a SCSI tape device that has  SCSI identifier 2 and
   performs  autorewinding; and  uussrr indicates the  file system  mounted on
   /uussrr. For a  list of recognized tape devices, see  the article for ttaappee.
   in the Lexicon.

   Please note  two points about _d_i_r_e_c_t_o_r_y. First, do  _n_o_t use the absolute
   path name when specifying a directory:  that is, use uussrr, _n_o_t /_u_s_r. ggttaarr
   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 will need
   to mount that file system by hand before you begin to back it up.

   Note that  the zz option  to the ggttaarr  command tells ggttaarr to  use ggzziipp 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3. When ggttaarr 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  <ccttrrll-D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 ggttaarr command to fetch  the file you want.
For example,  to restore file  /vv/ffwwbb/mmyyffiillee.c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v/ffwwbb, then mmyyffiillee.cc
will be restored into a file with the path name /vv/ffwwbb/vv/ffwwbb/mmyyffiillee.cc. This
may be a  little inconvenient, but is not nearly  as inconvenient as having
to create mmyyffiillee.cc by hand.

_A_n _E_x_a_m_p_l_e _o_f _U_s_i_n_g _F_l_o_p_p_y _T_a_p_e
The  following paragraphs  show examples  of how to  read and  write backup
archives to floppy tape.  It  uses the commands ttaappee, which manipulates the
tape device;  and ggttaarr, which  writes archives onto the  physical tape, and
reads them back.

Suppose you  have a directory  named ddiirr11 that  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 ggttaarr
again in 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 files backed up onto  a tape.  Do not be surprised
if an otherwise sound tape fails  after time; tapes 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 ggttaarr's option -z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 FFiilleess  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, ddiirr22, and you want  to back it up on the same
tape, after an archive of ddiirr11. 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 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 ttaappee tteellll 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 ttaappee tteellll 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 ttaappee sseeeekk moves the tape to the byte position 110022440000, i.e., the
end of  the first archive.  This  command assumes that you  jotted down the
position displayed  by the  command ttaappee  tteellll executed earlier.   The ggttaarr
command then displays the contents of the second archive.

_S_e_e _A_l_s_o
AAddmmiinniisstteerriinngg CCOOHHEERREENNTT, ggnnuuccppiioo, ggttaarr, ttaappee
