Relative and Absolute Backups


Contents

About This Document
About Relative and Absolute Backups
Relative and Absolute Backups with the tar Command
Relative and Absolute Backups with backup and restore

About This Document

This document applies to AIX Versions 3.2 and 4.1 and explains how the tar command and the backup and restore commands can be used for relative and absolute backups. In the examples in this document, the only flags used are the minimum necessary to accomplish the specified task.

NOTES:

  1. Unless used in an example, the words "backup" and "restore" do not refer to specific commands, but instead refer to the processes of putting data into an archive image and retrieving the data back from that image.
  2. The examples in this document use tape to contain the archive image, but a file could be used as well.
  3. The examples use the following directory structure:
       parent   subdir   subdir 
       /home 
                /tom 
                /sue 
                /rich 
                         /mystuff 
    

About Relative and Absolute Backups

Absolute
This is a backup that can only be restored to a directory structure identical to the one from which it was made. In the table of contents or the headers on the archive media, the path name will start with a "/".

The main advantage of this type of a backup is that you can restore the entire image without knowing where individual files are to be placed. An example would be a distribution image of a program or data.

The main disadvantage of this type of a backup is that the files can only be restored to the same location from which they were backed up.

Relative
This is a backup that will be restored starting from the current directory and will create directories as required depending on the flags specified. There is more flexibility with relative backups in the sense that the files (or directories) can be restored to any directory on the system.

The advantages of this type of a backup is that you can restore one or more directories to /tmp (for example) and then selectively copy the files that need to be recovered to the destination directory. Make sure it is the proper directory before starting the restore.

The main disadvantage of this type of backup is that it will restore the data to the directory that is current when the command is issued.


Relative and Absolute Backups with the tar Command

Creating an Absolute Backup

To make an ABSOLUTE backup of the file structure, enter:

   tar -cvf /dev/rmt0 /home/tom /home/sue /home/rich 

This will back up the directories tom, sue, rich, and all of their subdirectories. It will not back up any files in the /home directory but, upon restore, will ensure that the /home directory is created if it did not exist.

The following command will back up directories in the same manner as the previous example but will also get any files in the /home directory. Enter:

   tar -cvf /dev/rmt0 /home 

Creating a Relative Backup

To make a RELATIVE backup of the file structure, enter:

   cd /home 
   tar -cvf /dev/rmt0 tom sue rich 

This will back up the directories tom, sue, rich, and all of their subdirectories. It will not back up any files in the /home directory. The files will be restored relative to the current directory.

The following will back up the user directories in the same manner as the preceding example but will also get the files in the /home directory. Enter:

   cd / 
   tar -cvf /dev/rmt0 ./home 

Verifying and Listing the Table of Contents

The command to verify a tape created with tar or to list the table of contents of a tar tape is:

    tar -tvf /dev/rmt0 

The table of contents for the archive created with tar -cvf /dev/rmt0 /home/tom /home/sue /home/rich will have the following entries (only the file name is shown here):

   /home/tom 
   /home/sue 
   /home/rich 
   /home/rich/mystuff 

The table of contents for the archive created with tar -cvf /dev/rmt0 /home will have the following entries (only the file name is shown here):

   /home 
   /home/tom 
   /home/sue 
   /home/rich 
   /home/rich/mystuff 

The table of contents for the archive created with cd /home, tar -cvf /dev/rmt0 tom sue rich will have the following entries (only the file name is shown here):

   tom 
   sue 
   rich 
   rich/mystuff 

The table of contents for the archive created with cd /, tar -cvf /dev/rmt0 ./home will have the following entries (only the file name is shown here):

   ./home 
   ./home/tom 
   ./home/sue 
   ./home/rich 
   ./home/rich/mystuff 

Determining Whether a Backup Is Relative or Absolute

To determine if a tar tape was created as a relative or absolute backup, use the previous command for verifying a tape and examine the list of files. If the file names start with a "/", the backup is ABSOLUTE. Anything else is a RELATIVE backup.

Indicating Data to be Restored

To restore a file or directory from a tar tape, the name must be specified exactly as shown in the table of contents on the backup media. Use tar -tvf /dev/rmt0 to see how the files appear on the media. Multiple files and directories may be specified on the command line.

Restoring from a Relative Backup

The following will restore the directories tom, sue, their files, and their subdirectories. In this example, it is assumed that the archive was made with the script cd /home, tar -cvf /dev/rmt0 tom sue rich:

   cd /home 
   tar -xvf /dev/rmt0 tom sue 

The following will restore the entire tape into the /home directory. This example assumes that the archive was made with the script cd /home, tar -cvf /dev/rmt0 tom sue rich:

   cd /home 
   tar -xvf /dev/rmt0 

Use the following commands to restore a file or directory to a directory other than the one from which it was backed up. A reason to do this is to avoid overwriting particular existing files. This example assumes the archive was made with the script cd /, tar -cvf /dev/rmt0 ./home:

   cd /tmp 
   tar -xvf /dev/rmt0 ./home/rich/mystuff 

The result is:

   /tmp 
      /home             <-- no files or other directory entries 
         /rich          <-- no files or other directory entries 
            /mystuff 
               (files) 

Restoring from an Absolute Backup

The following will restore the directories tom, sue, their files, and their subdirectories to the /home directory. This will work with the archive created in tar -cvf /dev/rmt0 /home/tom /home/sue /home/rich: or tar -cvf /dev/rmt0 /home:

   tar -xvf /dev/rmt0 /home/tom /home/sue 

The following will restore the /home directory, its files, and its subdirectories from the archive created in tar -cvf /dev/rmt0 /home:

   tar -xvf /dev/rmt0 /home 

Relative and Absolute Backups with backup and restore

Creating an Absolute Backup

To make an ABSOLUTE backup of the file structure, you could use the following command:

   find /home/tom /home/sue /home/rich -print | backup -ivf /dev/rmt0 

It will back up the directories tom, sue, rich, and all of their subdirectories. It will not back up any files in the /home directory but, upon restore, will ensure that the /home directory is created if it does not exist.

The following will back up the directories in the same manner as the previous example but will also get any files in the /home directory.

   find /home -print | backup -ivf /dev/rmt0 

Creating a Relative Backup

To make a RELATIVE backup of the file structure, enter:

   cd /home 
   find tom sue rich -print | backup -ivf /dev/rmt0 

This will back up the user directories tom, sue, rich, and all of their subdirectories. It will not back up any files in the /home directory. The files will be restored relative to the current directory.

The following will back up the directories in the same manner as the previous example but will also get the files in the /home directory, with the exception of any .* files in the /home directory.

   cd /home 
   find . -print | backup -ivf /dev/rmt0 

Verifying and Listing the Table of Contents

The command to verify a tape created with the backup command or to list the table of contents of the tape is:

    restore -Tvf /dev/rmt0 

The table of contents for find /home/tom /home/sue /home/rich -print | backup -ivf /dev/rmt0 will have the following entries (only the file name is shown here):

   /home/tom 
   /home/sue 
   /home/rich 
   /home/rich/mystuff 

The table of contents for find /home -print | backup -ivf /dev/rmt0 will have the following entries (only the file name is shown here):

   /home 
   /home/tom 
   /home/sue 
   /home/rich 
   /home/rich/mystuff 

The table of contents for cd /home, find tom sue rich -print | backup -ivf /dev/rmt0 will have the following entries (only the file name is shown here):

   tom 
   sue 
   rich 
   rich/mystuff 

The table of contents for cd /home, find . -print | backup -ivf /dev/rmt0 will have the following entries (only the file name is shown here):

   . 
   ./tom 
   ./sue 
   ./rich 
   ./rich/mystuff 

Determining Whether a Backup Is Relative or Absolute

To determine whether a tape created by the backup command is relative or absolute, use the previous command for verifying a tape and examine the list of files. If the file names start with a "/", the backup is ABSOLUTE. Anything else is a RELATIVE backup.

Indicating Data to be Restored

To restore a file or directory from a backup tape, the name must be specified exactly as shown in the table of contents on the backup media. Use tar -tvf /dev/rmt0 to see how the files appear on the media. Multiple files and directories may be specified on the command line.

Restoring from a Relative Backup

The following command will restore the directories tom and sue, their files, and their subdirectories from the archive created in cd /home, find tom sue rich -print | backup -ivf /dev/rmt. The -d flag indicates that the names specified are directories and that all files in the directories should be restored.

   cd /home 
   restore -xdvf /dev/rmt0 ./tom ./sue 

The following will restore all of the data on the tape into the current directory from the archive created in cd /home, find . -print | backup -ivf /dev/rmt0.

   cd /home 
   restore -xvf /dev/rmt0 

Use the following commands to restore a file or directory to a directory other than the one from which it was backed up. A reason to do this is to avoid overwriting particular existing files. The following example works for the archive created in cd /home, find . -print | backup -ivf /dev/rmt0.

   cd /tmp 
   restore -xvdf /dev/rmt0 ./home/rich/mystuff 

The result is:

   /tmp 
      /home             <-- no files or other directory entries 
         /rich          <-- no files or other directory entries 
            /mystuff 
               (files) 

Restoring from an Absolute Backup

The following will restore the directories tom and sue, their files, and their subdirectories to the /home directory. The -d flag indicates that the names specified are directories and that all files in the directories should be restored. This example assumes the archive was made with the script in find /home/tom /home/sue /home/rich -print | backup -ivf /dev/rmt0, or find /home -print | backup -ivf /dev/rmt0.

   restore -xdvf /dev/rmt0 /home/tom /home/sue 

The following will restore the /home directory, its files, and its subdirectories. This example assumes the archive was made with the script in find /home -print | backup -ivf /dev/rmt0.

   restore -xdvf /dev/rmt0 /home 


Relative and Absolute Backups: rel.abs.bkup.32.41.bak ITEM: FAX
Dated: 99/05/07~00:00 Category: bak
This HTML file was generated 99/06/24~12:41:56
Comments or suggestions? Contact us