DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Working with disks, tapes, and CD-ROMs

Extracting files from a tar backup

To extract files from a tar backup, the format is as follows:

tar xvf device files

tar looks at the backup on device (or the file of that name), extracts all the files which match files, and places them relative to the current directory. Note that tar does not understand wildcards so files should be a list of explicit filenames.

   $ tar xvf /dev/rfd096ds15
This command line restores the contents of the backup as held on /dev/rfd096ds15. The x option tells tar to extract files, v displays them, and f tells tar to use the next argument (/dev/rfd096ds15) as the name of the backup.

(If the use of wildcards is especially important, you should use the cpio(C) command instead of tar; see ``Creating a backup with cpio'' for details.)

If, when you created the backup, you gave tar a full pathname, the files will be restored to their original location. If you gave tar a relative pathname, you can restore the files to a different location.

You can tell whether the files in a tar archive have full pathnames by listing the files in the archive; if their names begin with a slash (/) they will be extracted relative to the root directory. For example, the files in the following archive will be placed in the root directory (unlike the files in the previous example):

   $ tar tvf /dev/rfd096ds15
   rw-r--r--13079/1014    713 Dec 17 11:10 1992 /README
   rw-rw-r--13079/1014     77 Dec 17 09:33 1992 /00.partno.nr.Z
   rw-rw-r--13079/1014   1887 Dec 17 09:33 1992 /00.title.nr.Z
   rw-rw-r--13079/1014   8735 Dec 17 09:36 1992 /00.toc.nr.Z
   rw-rw-r--13079/1014   5961 Dec 17 09:37 1992 /01.intro.nr.Z
   rw-rw-r--13079/1014  61179 Dec 17 09:44 1992 /02.op.nr.Z
You can override full pathnames by specifying the A option, which makes tar write the files as though your current directory is the root directory. For example, the file /README (as above) is normally unpacked and placed in the root directory; but if you restore it by using the command tar xvA while your current directory is /u/charles the file will be placed in /u/charles/README.
Next topic: Creating a backup with cpio
Previous topic: Listing the files in a tar backup

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003