************* BACK AND FORTH PAGING SUBROUTINE ************

PAGEFLOP

If they want to quit, do so
 If They want to quit subsession, Do SO!
Decrement LOCAL and GLOBAL Page Counters

FORWARD

  Increment LOCAL and GLOBAL Page Counters
   *************** END PAGEFLOP *********************
  ****** CHAPTER INTERNAL SELECTOR ALGORITHM ******

SELECTOR

   Reset Local Page Counter

SELAGAIN

 CHECK IF ONLY A <CR>

WRONGSEL

YOUR SELECTION IS NOT IN THE 0 - #SELIMIT  RANGE  Please try again

GO

Copyright CourseWare Technologies Inc., 1985-88


Lesson - 7


 BACKUP AND RESTORE PROCEDURES 

MENU

Backups-Restores|Topics to Learn|7-0|12,44
   #             Topic
  ---           -------
   1   -   Purpose of Backups
   2   -   Backup Types
   3   -   Selecting A Backup Strategy
   4   -   Backing Up with the tar Command
   5   -   Backing Up with the cpio Command
   6   -   Backing Up with the backup/dump Command
   7   -   Restoring Files and Directories
   8   -   Other Backup Utilities
   9   -   Lesson Review
   8   -   Lesson Review
   0   -   Return to the Main Menu

P1

Backups-Restores|Purpose of Backups|7-1.1|4,55
Backing up is the process of saving the data from  
your computer's hard disk(s) onto a 9-track tape, 
data cartridge, diskettes, or other form of removable 
storage media.

P2

Backups-Restores|Purpose of Backups|7-1.2|10,53
     Data loss occurs due to equipment failure and 
human error.


     Backups are done to enable the recovery of 
lost data/files.


     The procedure of recovering or copying the data 
from the backup media back to the hard disk is called 
restoring.

P3

Backups-Restores|Backup Types|7-2.1|7,50
There are two types of backups:

     1.  Full or epoch backups save all of the 
     data on the entire computer system.

     2.  Incremental backups save only the data 
     that was modified since the last full backup.

P4

Backups-Restores|Backup Types|7-2.2|12,58
     Incremental backups can be set up to save all of
the data since:

       * The last full backup
       * The last incremental backup
       * an incremental backup of a specified number of 
         days ago.


     One must keep in mind that the most complete backup 
permits the fastest complete restore; however, it requires 
the maximum media and maximum backup time.

P5

Backups-Restores|Selecting A Backup Strategy|7-3.1|9,52
     Since you do not want to lose the information on 
your system disk due to mechanical failure or human 
error, it is important that you do frequent backups of 
your files.


     One should select the backup strategy that will 
optimize data security, backup-restore time, and 
media requirements.

P6

Backups-Restores|Selecting A Backup Strategy|7-3.2|10,58
     It is suggested that whenever a significant amount
of new data is being added or changed, a backup of at 
least the new information should be done on a daily
basis!


     A full dump every week is recommended.  You should 
perform an incremental backup daily.  Furthermore a 
strategy has to be devised so there is an overlap of 
backed up data in case a volume is lost.

P7

Backups-Restores|Selecting A Backup Strategy|7-3.3|7,60
     We shall discuss the following backup and recovery tools: 

            *  tar (for tape archiver), 
            *  cpio (for copy archives in and out),
            *  volcopy,
            *  dump/backup, and
            *  restore.

P8

Backups-Restores|Selecting A Backup Strategy|7-3.4|13,54
First, we'll compare the various commands, then we'll 
describe each one in detail.

   The tar command:
      *  won't automatically locate modified files,
      *  is very reliable and portable, and
      *  works recursively, i.e., maintains the tree 
         hierarchy.

   The dump or backup command is:
      *  faster than tar or cpio,
      *  more efficient than tar or cpio, and
      *  leaves a time stamp.

P9

Backups-Restores|Selecting A Backup Strategy|7-3.5|14,54
The cpio command:
   *  is more space efficient than tar,
   *  has an archive containing pathname and status 
      information,
   *  has a format portable across all UNIX-like 
      systems, BUT
   *  is more difficult to use, and
   *  does not handle directory hierarchies.

The volcopy command:
   *  is just for System V, 
   *  does label checking, and
   *  creates new volumes that do not have files scattered
      all over the disks.

P10

Backups-Restores|Selecting A Backup Strategy|7-3.6|10,50
     The tar and cpio commands permit the system 
manager and ordinary users to make copies of the 
desired directories and files.  However, these commands 
do not automatically locate modified files.


     You have to use the find command to build the
list of modified files and use this list as an
argument to tar and cpio commands.

P11

Backups-Restores|Backups Using tar|7-4.1|5,53
     The tar command is one of the most reliable 
commands for data storage, portability and recovery.
It was originally designed to operate on magnetic 
tapes; however it also permits one to copy files to
or from other magnetic disks.

P12

Backups-Restores|Backups Using tar|7-4.2|11,55
     The  format of the tar command for archiving is:

tar  cvf  specialfile  files

where f expects specialfile to be the name of the file
corresponding to a disk drive, c creates a new archive, 
and v is for verbose.


     Unless otherwise indicated, the default device 
for tar is the magnetic tape drive.

P13

Backups-Restores|Backups Using tar|7-4.3|5,54
     If a file system is mounted on the directory a1,
to back up that file system onto the device rfd0, the 
command would be:

tar  cf  /dev/rfd0  /a1

P14

Backups-Restores|Backups Using tar|7-4.4|11,51
     The tar command works recursively when copying 
a file system.  It assumes that the second argument 
is a directory; therefore it looks for files in that 
directory.  If it finds another directory, it tries 
to copy the files from that directory until there are 
no directories on the lower levels.


If the argument is an ordinary file then obviously 
there are no files below it, and tar copies only 
that file in the hierarchy.

P15

Backups-Restores|Backups Using tar|7-4.5|14,57
      The command to copy all of the files on the system 
to tape drive 5, is:

tar  c5  /

Note:  Make sure that your archiving medium is large 
enough for storing all the files that you plan to back up!


      To archive the entire current directory into the 
file admin.tar, you would use the following command:

tar  cf  admin.tar  *

P16

Backups-Restores|Backups Using tar|7-4.6|10,46
     To check the contents of the new archive 
called admin.tar, the command would be:

tar  tf  admin.tar


     To copy the entire tree-structure of the 
current directory to a  directory called 
/a/bin/distribute, use:

tar cf - . | (cd /a/bin/distribute; tar xf -)

P17

Backups-Restores|Backups Using cpio|7-5.1|8,52
     The cpio command (copy archives in and out) 
is similar to tar.  It copies files into and out 
of an archive.  The archive contains pathname and 
status information.  However, rather than reading 
the pathnames, cpio reads the standard input to 
obtain a list of pathnames and copies those files 
onto the standard output together with the pathname 
and status information.

P18

Backups-Restores|Backups Using cpio|7-5.2|12,60
     The format of the cpio archiving command is:

ls pathname(s) -print | cpio -ocBv > specialfile

    pathname  is the pathname of every file to be 
              archived; 
 specialfile  is the name of the file corresponding to
              a disk drive; 
          B   means to Block 5120 bytes per record; 
          c   means to create ASCII header information;
          v   indicates to verbosely list the filenames.

P19

Backups-Restores|Backups Using cpio|7-5.3|12,54
     To archive all files and subdirectories in the 
/usr/CTI directory and put them on the storage




find /usr/CTI -print | cpio -ocBv > /dev/rst
find /usr/CTI -print | cpio -ocBv > /dev/fd0
find /usr/CTI -print | cpio -ocBv > /dev/rmt0


     The command to produce a cpio archive of all 
of the files ending in .c and put them on the device 
/dev/rfd148ds9 would be:

ls  *.c  |  cpio  -oBv  >  /dev/rfd148ds9

P20

Backups-Restores|Backups Using backup/dump|7-6.1|10,55
     When the number of users on the system grows, a 
special-purpose backup utility like backup or dump 
should be used because:

     *  It is faster than tar or cpio.

     *  It is more efficient than tar or cpio.

     *  It leaves a time stamp in a special file of the 
        backup level.

P21

Backups-Restores|Backups Using backup/dump|7-6.2|13,54
     The actual command that performs backup is backup 
under UNIX.  Under 4.3 BSD systems the utility that 
performs an identical function is dump.


     The syntax for the backup and dump commands is:

backup  [options  [device name]  file system]

dump  [options  [device name]  file system]

where the device name is the name of the tape device and 
file system is the name of the file system to be dumped.

P22

Backups-Restores|Backups Using backup/dump|7-6.3|5,54
     Depending on the options and arguments chosen, the 
backup utility can save from single files to entire 
file systems.  Furthermore, it allows you to select 
data to backup based on a specified time of last 
modification.

P23

Backups-Restores|Backups Using backup/dump|7-6.4|9,52
     The backup level (0-9) permits one to specify 
which files to backup for the same file system from
the last date stored in the /etc/ddate (or 
/etc/dumpdates for BSD systems) for the same file 
system.


     Level 0 causes the entire file system to be
backed up.

P24

Backups-Restores|Backups Using backup/dump|7-6.5|10,56
     Similarly, backup/dump permits one to perform
incremental backups of various levels. 

Note how the command interprets the backup dates:

     *  Level 9 causes the files modified since last 
        full backup to be backed up.

     *  Level 5 causes the files modified since the 
        last level 5 or higher backup to be backed up.

P25

Backups-Restores|Restoring Files and Directories|7-7.1|14,54
     Restoring files from archives is the opposite of
the backup procedure.  You may restore single files as 
well as entire file systems.


     The program to use for restoring files depends upon
which program was used for the archive:

 program used to make archive    program used to restore
 ----------------------------    -----------------------
           tar                           tar
           cpio                          cpio
           dump                          restore
           backup                        restore

P26

Backups-Restores|Restoring Files and Directories|7-7.2|15,55
Some general points about restoring files:

     Never restore a file to it's original directory.
(You could overwrite a better version.) You must make 
a new directory (and make sure the user owns it) or 
restore files to /usr/tmp.


     When restoring files, you must know whether
your system restores the files by names or inode 
numbers.


     Often you must specify the complete pathname of 
the desired file.  

P27

Backups-Restores|Restoring Files and Directories|7-7.3|12,55
Some more general points about restoring files:

     If the system restores the files by their inode 
numbers, you will have to move the file to the desired 
name, e.g.:

mv  337  /usr/CTI/admin/7sa


     After restoring files, check the ownership and 
permissions and send a message to the user telling him 
or her where the files are.

P28

Backups-Restores|Restoring Files and Directories|7-7.4|15,55
     Prior to restoring files or file systems, it
is a good idea to check the table of contents of the 
volume from which you plan to restore these files.


     As you saw earlier, the tar command that allows one 
to check the contents of an archive is:

tar  tvf  archive name  


     The restore command which allows you to check 
the contents of an archive that was made using dump is:

restore  t  

P29

Backups-Restores|Restoring Files and Directories|7-7.5|10,51
     The command that allows you to check the
table of contents on an archive made with cpio is:

cpio  -t


     The command that allows one to check the table 
of contents on an archive made with backup is:

dumpdir

P30

Backups-Restores|Restoring with tar|7-7.6|14,45
     With the tar program, you may restore an 
entire archive, a directory, or a single file.


     The syntax for using the tar command to 
restore all files from the disk is:

tar  xvf  specialfile


     For example, the command to restore




tar xvf /dev/fd1
tar xvf /dev/rst
tar xvf /dev/rmt0

P31

Backups-Restores|Restoring with tar|7-7.7|12,54
     To restore a single file or directory you need
to list the contents of the directory.  For example,
to get a verbose listing of the archive /dev/rfd0 
with a blocking factor of 20 you would type:

tar  tvbf  20  /dev/rfd0


     To restore all files starting with the directory 
name cti from the archive /dev/rfd0, you would use 
the command:

tar  xf  /dev/rfd0  cti/*

P32

Backups-Restores|Restoring with cpio|7-7.8|13,55
     The command to extract all the files that are archived 
in cpio format is:

cpio  -i  [Bcdmrtuv] [patterns]

where patterns can be any of the name-generating notations
of sh or csh.

For example, to restore all of the files whose names end in 
*.summary from the device /dev/fd1 
the command would be:

cpio  -idv  *.summary  <  /dev/fd1

P33

Backups-Restores|Restoring with restore|7-7.9|9,46
     For files archived with backup or dump the
restore function is performed with the restore 
command.  


     It is possible to restore:

         *  1 or more particular files or
         *  an entire file system.
Backups-Restores|Restoring with restore|7-7.9|13,46
     For files archived with backup or dump the
restore function is performed with the restore 
command.  


     It is possible to restore:

         *  1 or more particular files or
         *  an entire file system.


     The restore function is also available 
through the sysadmin menu.
Backups-Restores|Restoring with restore|7-7.9|16,50
     For files archived with backup or dump the
restore function is performed with the restore 
command.  


     It is possible to restore:
         *  1 or more particular files or
         *  an entire file system.


     The restore function may also be available 
through the admin menu.


     Note that the utility volcopy may be used
to perform full restores as well.

P34

Backups-Restores|Restoring Files with restore|7-7.10|12,55
     The general steps for restoring files are:

  1.  locate the appropriate tape(s), 
  2.  mount the tape,
  3.  determine the name of the device it's mounted on,
  4.  cd /usr/tmp to avoid overwriting files with the same name,
  5.  type restore t to read the table of contents,
  6.  identify the files to be restored,
  7.  restore the files with restore,
  8.  check ownership and permissions, and
  9.  notify the owner about the location of the restored 
      files.

P35

Backups-Restores|Restoring Files with restore|7-7.11|12,55
     You can also use the restore command interactively  
by typing restore -i   When you do so, you can browse 
through directories to create a list of files to be 
restored using interactive commands like: 

         help - display a summary of available commands
       cd dir - change to the named directory
     ls [dir] - list the files in dir
     add file - add the named file to the list of 
                files to extract
  delete file - delete the named file from the list
      extract - extract all files on the list

P36

Backups-Restores|Restoring Files with restore|7-7.12|12,55
     The command to rewind a reel of 1/2 inch tape and 
take it off-line is:

mt  offline

     For 1/4 inch tapes (on data cartridges) you must 
add a option to indicate which device.  The command to 
do this is

mt  -f  /dev/devicename  offline

P37

Backups-Restores|Restoring Files and Directories|7-7.13|7,52
Backups-Restores|Restoring Files and Directories|7-7.11|7,52
     Backup and restore procedures may not be the
most interesting tasks; however, they are some of
the most important system maintenance tasks.


     As a system administrator, you should
understand these clearly prior to storing important 
files on your system.

P38

Backups-Restores|Other Backup Utilities|7-8.1|11,56
     The command volcopy can be used to backup or copy 
entire file systems (with label checking) to mounted 
volumes.  This utility is similar to the DOS copy 
utility.  To copy volume 2 of the file system is mounted 
on device /dev/rfd0 onto volume 1 of /dev/rfud1 use:

volcopy  is  /dev/rfd0  2  /dev/rfud1  1


     Many UNIX systems offer a menu-level interface 
for performing backups.
Backups-Restores|Other Backup Utilities|7-8.1|6,54
     Many UNIX systems offer a menu-level interface 
for performing backups.


     Under Xenix this utility is called sysadmin 
which uses the backup command.

P39

Backups-Restores|Other Backup Utilities|7-8.2|14,60
     To use the system backup utility sysadmin

     1.   Login as root.
     2.   Type at the prompt:  sysadmin.  The program
          will display the file system maintenance menu, e.g.:
                   File System Maintenance
                   -----------------------
                   1  to do daily backup
                   2  to do a periodic backup
                   3  to get a backup listing
                   4  to restore a file
                   5  to quit
     3. Select the desired choice and follow the interactive 
        procedure.
Backups-Restores|Other Backup Utilities|7-8.2|14,60
     The command for specifying initial labels for 
unmounted disks and file systems is /etc/labelit.  The
labels produced by labelit are used by volcopy when 
copying files onto these mounted file systems.


     When used with no arguments, labelit prints 
the label information on the file system.


     The command to specify label mt of version mt.3 
for a new magnetic tape on device /dev/rmt3 is:

labelit  /dev/rmt3  mt  mt.3  -n