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, backup, and restore commands can be used for relative and absolute backups. The examples provided in this document use only the minimum flags that are 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 process 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 an absolute 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 an absolute 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 because the files (or directories) can be restored to any directory on the system.

The advantages of a relative backup are 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. Ensure it is the proper directory before starting the restoration.

The main disadvantage of a relative 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 create 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 already exist.

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

   tar -cvf /dev/rmt0 /home 

Creating a relative backup

To create 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 command will back up the user directories in the same manner as the preceding example and will also place 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 examining 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 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. One reason for doing 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 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 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 create 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 create 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 and will also place 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 examining 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 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. This will 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 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 subdirectories. This example assumes the archive was made with the script in find /home -print | backup -ivf /dev/rmt0.

   restore -xdvf /dev/rmt0 /home 




[ Doc Ref: 90605197814818     Publish Date: May. 19, 2000     4FAX Ref: 2702 ]