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 <-- no files or other directory entries /rich <-- no files or other directory entries /mystuff (files) Restoring from an Absolute Backup The following command would restore the directories tom, sue, their files, and their subdirectories to the /home directory. This would work with the archive created in Figure 1 (tar.abs.1) or Figure 2 (tar.abs.2). tar -xvf /dev/rmt0 /home/tom /home/sue The following would restore the /home directory, its files, and its subdirectories from the archive created in Figure 2 (tar.abs.2). tar -xvf /dev/rmt0 /home RELATIVE AND ABSOLUTE BACKUPS WITH BACKUP/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 | | | +--------------------------------------------------------------------+ Figure 5. backup.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 would back up the user directories in the same manner as the previous example but would also get any files in the /home directory. +--------------------------------------------------------------------+ | | | find /home -print | backup -ivf /dev/rmt0 | | | +--------------------------------------------------------------------+ Figure 6. backup.abs.2 Relative and Absolute Backups 5 01/25/96, 4FAX# 2702 Creating a Relative Backup To make a RELATIVE backup of the file structure, you could use the following commands: +--------------------------------------------------------------------+ | | | cd /home | | find tom sue rich -print | backup -ivf /dev/rmt0 | | | +--------------------------------------------------------------------+ Figure 7. backup.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 with the exception of any .* files in the /home directory. +--------------------------------------------------------------------+ | | | cd /home | | find . -print | backup -ivf /dev/rmt0 | | | +--------------------------------------------------------------------+ Figure 8. backup.rel.2 Verifying/Listing the Table of Contents The command to verify a tape created with the backup command or to list the table of contents (TOC) of the tape is: restore -Tvf /dev/rmt0 The TOC for Figure 5 (backup.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 Figure 6 (backup.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 Figure 7 (backup.rel.1) would have the following entries (only the file name is shown here): Relative and Absolute Backups 6 01/25/96, 4FAX# 2702 tom sue rich rich/mystuff The TOC for Figure 8 (backup.rel.2) would have the following entries (only the file name is shown here): . ./tom ./sue ./rich ./rich/mystuff Determining Whether 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(s) or directory(s) from a backup 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 "restore -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 from the archive created in Figure 7 (backup.rel.1). 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 would restore all of the data on the tape into the current directory from the archive created in Figure 8 (backup.rel.2). cd /home restore -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. The following example works for the archive created in Figure 8 (backup.rel.2). cd /tmp restore -xvdf /dev/rmt0 ./home/rich/mystuff Relative and Absolute Backups 7 01/25/96, 4FAX# 2702 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 command would restore the directories tom, 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 Figure 5 (backup.abs.1) or Figure 6 (backup.abs.2). restore -xdvf /dev/rmt0 /home/tom /home/sue The following would restore the /home directory, its files, and its subdirectories. This example assumes the archive was made with the script in Figure 6 (backup.abs.2). restore -xdvf /dev/rmt0 /home Relative and Absolute Backups 8 01/25/96, 4FAX# 2702 READER'S COMMENTS Please fax this form to (512) 823-4009, attention "AIXServ Informa- tion". You may also e-mail comments to: elizabet@austin.ibm.com. These comments should include the same customer information requested below. Use this form to tell us what you think about this document. If you have found errors in it, or if you want to express your opinion about it (such as organization, subject matter, appearance) or make sug- gestions for improvement, this is the form to use. If you need technical assistance, contact your local branch office, point of sale, or 1-800-CALL-AIX (for information about support offer- ings). These services may be billable. Faxes on a variety of sub- jects may be ordered free of charge from 1-800-IBM-4FAX. Outside the U.S. call 415-855-4329 using a fax machine phone. When you send comments to IBM, you grant IBM a nonexclusive right to use or distribute your comments in any way it believes appropriate without incurring any obligation to you. NOTE: If you have a problem report or item number, supplying that number may help us determine why a procedure did or did not work in your specific situation. Problem Report or Item #: Branch Office or Customer #: Be sure to print your name and fax number below if you would like a reply: Name: Fax Number: ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ END OF DOCUMENT (rel.abs.backup.bak, 4FAX# 2702) Relative and Absolute Backups 9