01/25/96, 4FAX# 2702
Relative and Absolute Backups
SPECIAL NOTICES
Information in this document is correct to the best of our
knowledge at the time of this writing. Please send feedback
by fax to "AIXServ Information" at (512) 823-4009.
Please use this information with care. IBM will not be
responsible for damages of any kind resulting from its use.
The use of this information is the sole responsibility of
the customer and depends on the customer's ability to eval-
uate and integrate this information into the customer's
operational environment.
ABOUT THIS DOCUMENT
This document explains how the tar command and the
backup/restore commands can be used for relative and abso-
lute backups and is applicable to AIX versions 3.2 and 4.1.
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 user 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 it was
made from. If you list 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.
Relative and Absolute Backups 1
01/25/96, 4FAX# 2702
The main disadvantage of this type of a backup is
that you can only restore the files to the same
location from which you backed them up.
RELATIVE This is a backup that will be restored starting
from the current directory and will create direc-
tories as required depending on the flags speci-
fied.
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
you need to recover to the destination directory.
You must ensure that you are in the proper direc-
tory before starting the restore.
The main disadvantage of this type of restore is
that it will restore the data to the directory
that is current when you issue the command.
RELATIVE AND ABSOLUTE BACKUPS WITH THE TAR COMMAND
Creating an Absolute Backup
To make an ABSOLUTE backup of the file structure, you could
use the following command:
+--------------------------------------------------------------------+
| |
| tar -cvf /dev/rmt0 /home/tom /home/sue /home/rich |
| |
+--------------------------------------------------------------------+
Figure 1. tar.abs.1
It would back up the user directories tom, sue, rich, and
all of their subdirectories. It would not back up any files
in the /home directory but upon restore would ensure that
the /home directory was created if it did not exist.
The following command would back up the user directories in
the same manner as the previous example but would also get
any files in the /home directory.
+--------------------------------------------------------------------+
| |
| tar -cvf /dev/rmt0 /home |
| |
+--------------------------------------------------------------------+
Figure 2. tar.abs.2
Creating a Relative Backup
To make a RELATIVE backup of the file structure, you could
use the following commands:
Relative and Absolute Backups 2
01/25/96, 4FAX# 2702
+--------------------------------------------------------------------+
| |
| cd /home |
| tar -cvf /dev/rmt0 tom sue rich |
| |
+--------------------------------------------------------------------+
Figure 3. tar.rel.1
This would back up the user directories tom, sue, rich, and
all of their subdirectories. It would not back up any files
in the /home directory. The files would be restored rela-
tive to the current directory.
The following would back up the user directories in the same
manner as the previous example but would also get the files
in the /home directory.
+--------------------------------------------------------------------+
| |
| cd / |
| tar -cvf /dev/rmt0 ./home |
| |
+--------------------------------------------------------------------+
Figure 4. tar.rel.2
Verifying/Listing the Table of Contents
The command to verify a tape created with tar or to list the
table of contents (TOC) of a tar tape is:
tar -tvf /dev/rmt0
The TOC for the archive created in Figure 1 (tar.abs.1)
would have the following entries (only the file name is
shown here):
/home/tom
/home/sue
/home/rich
/home/rich/mystuff
The TOC for the archive created in Figure 2 (tar.abs.2)
would have the following entries (only the file name is
shown here):
/home
/home/tom
/home/sue
/home/rich
/home/rich/mystuff
The TOC for archive created in Figure 3 (tar.rel.1) would
have the following entries (only the file name is shown
here):
tom
sue
rich
rich/mystuff
Relative and Absolute Backups 3
01/25/96, 4FAX# 2702
The TOC for the archive created in Figure 4 (tar.rel.2)
would have the following entries (only the file name is
shown here):
./home
./home/tom
./home/sue
./home/rich
./home/rich/mystuff
Determining Whether 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 REL-
ATIVE backup.
Indicating Data to be Restored
To restore a file(s) or directory(s) from a tar tape, you
must specify the name exactly as shown in the table of con-
tents. Multiple files and/or directories may be specified
on the command line.
(Note: Specify the directory/file names as they appear on
the backup media. Use "tar -tvf /dev/rmt0" to see how the
files appear on the media.)
Restoring from a Relative Backup
The following command would restore the directories tom,
sue, their files, and their subdirectories. In this
example, it is assumed that the archive was made with the
script in Figure 3 (tar.rel.1).
cd /home
tar -xvf /dev/rmt0 tom sue
The following would restore the entire tape into the /home
directory. In this example, it is assumed that the archive
was made with the script in Figure 3 (tar.rel.1).
cd /home
tar -xvf /dev/rmt0
Use the following commands to restore a file(s) or
directory(s) 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 in Figure 4 (tar.rel.2).
cd /tmp
tar -xvf /dev/rmt0 ./home/rich/mystuff
The result is:
Relative and Absolute Backups 4
01/25/96, 4FAX# 2702
/tmp
/home