Help using pax to restore into current directory?

Hello,

I have a tape backup (it was made using dd/tar) and I want to use dd/pax to restore tape to disk, in IBM AIX 7.2.

I can restore from tape using example below without issues.

#/usr/bin/dd bs=128k if=/dev/rmt0 | /usr/bin/pax -r -v /home/c3rb3rus/utils/*

USTAR format archive
/home/c3rb3rus/utils/file1.txt
/home/c3rb3rus/utils/file1.txt
/home/c3rb3rus/utils/file1.txt

The problem is, I need to restore relative to some (or current) directory, so as long as it is not to original destination to prevent overwriting.

I tried messing with the -s (ReplacementString) parameter but I cannot seem to get it to work.

Anyone able to help me out?

That is why you better make the backup without the leading / , for example (cd / && tar cf - .) instead of tar cf - / .
But IMHO you can tell pax to make some modifications. RTFM:

man pax

RTFM? Really?

Did you even read the post? It clearly states I already tried using -s (ReplacementString) without success, how do you think I got to this parameter?

No, I cannot use cd/tar since I am doing this in a script and grabbing dozen or so different directives and sending them to tape.

Agreed.

Please do not answer user questions RTFM.

Better not to reply if anyone wants to post a RTFM reply which is not permitted at unix.com.

I found my answer here, using: -s '%^/%<relative_path>/%' works, for anyone else that may run into this.

1 Like

OK.

What did you exactly try with the "-s" parameter, because it basically does what you want it to do? And what was (exactly!) the outcome of what you tried? As long as the only description of what went wrong is "didn't work" it is hard to understand and tell you what you should have done differently (apart from the general advice of reading the manual. I take it you did that but obviously you didn't completely understand what it said.).

I hope this helps.

bakunin

Can you show example of that substitute failure ..

Here everything works as expected, but i'm not using tape device, but cat :slight_smile:

cat archive.tar | pax -s"#/archive/originalpath/#/some/restore/#g"

Above command should print out what will the effect be.
If you are happy with result, add -r to the end to restore.

Regards
Peasant.