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:
parent subdir subdir /home /tom /sue /rich /mystuff
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.
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.
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
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
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
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.
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.
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)
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
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
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
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
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.
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.
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)
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