How do I restore to a different location the contents of a

How do I restore to a different location the contents of a tarfile created with absolute pathnames?


Tarfiles should not normally be created with absolute pathnames, only
with relative pathnames. Do not type "tar c /path/name" to create a tar
archive, type "(cd /path/name; tar c .)" instead.

If you do have an archive created with absolute pathnames, you can unpack
it in a different location by using GNU's version of tar, which will strip
off the leading /.

Alternatively, you can use pax to strip off the leading /, as follows:

pax -r -s '/^\///'
Or you can use chroot and a statically linked version of tar, as follows:

cp /usr/sbin/static/tar /tmp/restore
# cd /tmp/restore
# cat abspath.tar | chroot /tmp/restore /tar xf -

Thanks to Fabrice Guerini



Home
FAQ