extracting tar files with absolute pathnames relatively

Kemp at dockmaster.arpa Kemp at dockmaster.arpa
Sat Apr 22 13:01:18 AEST 1989


Todd,
  I don't know of any good way to restore files from a tar tape that was
created with absolute pathnames, but I do have a couple of bad ways (if
you can become superuser, or get the cooperation of one).

 1) If you want to extract only files rooted in a directory that does
not exist on your system, then create a symbolic link to where you want
them to go.  For example if you don't currently have /usr/bin/foo, and
you want to restore files /usr/bin/foo/...  into /temp/foo/...,

 cd /usr/bin
 ln -s /temp/foo

    Or if /temp/foo is to be in the same partition as /usr/bin/foo, you
could just restore the tape as is, and then

 cd /usr/bin
 mv foo /temp/foo

  2) If /usr/bin/foo already exists and you don't want to mess with it,
or if the tape contains lots of different first level directories, you
could chroot to /tmp, restore the tape, and then mv the files to where
you want them.


 DISCLAIMER: I have used method #1, but not #2.

 MORAL:  **Don't** write tar tapes with absolute pathnames, unless you
are distributing system software.

     Dave Kemp



More information about the Comp.unix.questions mailing list