Index syndication
comment syndication

Solaris tar and changing absolute paths

August 17, 2007 at 13:24 · Filed under unix

On linux and other Unix like operating systems, you can untar a tar file with an absolute path to a different location. On Solaris using tar you can not. How do you get around this? Perderabo on the Unix for Advanced and Expert Users forum describes how. Here is an example (names and servers changed to protect the innocent):

 [email protected]:~ $ tar tvf data_backup.tar
-rwxrwx--- 13406/1201 2881056 Apr 26 19:29 2007 /apps/server/data/file
-rwxrwx--- 13406/1201 485376 Apr 26 19:29 2007 /apps/server/data/file.idx
[email protected]:~ $ pax -r -s '=^/apps/server=/home/you=' < data_backup.tar [email protected]:~ $ ls -l /home/you/data/ total 6624 -rwxr-x--- 1 d292462 strata 2881056 Apr 26 19:29 file -rwxr-x--- 1 d292462 strata 485376 Apr 26 19:29 file.idx

The key is the string given to pax '=^/apps/server=/home/you='. The /apps/server is the path you are replacing and the /home/you is the new path you are forcing tar to untar to. Mix and match as required. But the first string (/apps/server) is the part of the absolute path of each tarred file.

Now get to it.

Sunguy said,

April 5, 2012 @ 01:52


Udit said,

July 21, 2015 @ 17:42

Unbelievable!!!! You rock!

RSS feed for comments on this post · TrackBack URI

Leave a Comment