Link to home
Start Free TrialLog in
Avatar of kkrishna021799

asked on

UNIX - tar backup - restore files to a location different from original location

I backed up some files using tar from directory /usr1/ibs2/inps.  I wish to restore them to another directory say /usr2/ibs2/inps.

I cannot restore them to /usr1/ibs2/inps and later move them to the desired location as the former location contain live data and these cannot be overwritten.
Avatar of tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

Please see gheists answer in :

cd /usr2 && pax -r < /path/to/yourtarfile.tar

This will recreate the directory structure _under_ /usr2, e.g.
So when the untar is complete, just
cd /usr2/usr1 && mv ibs2 ..
Avatar of kkrishna021799


Thanks for the response.  Could you please explain syntax of your comment.  What do I replace "yourtarfile.tar" with.

As I explained in my query, I am trying to restore from tape into another directory.

Unfortunately, I am not a premium member and have no access to the link you suggested

cd /usr2  # And if successful, run the next command, i.e.
pax -r < /dev/rmt/0m  (Replace with the name of your tape device)

You may need to experiment with your version of "pax", e.g. using the -f option.
pax -r -f /dev/rmt/0m
While testing, if you omit the "-r" option, pax should just list the contents of the achive "device" without writing anything

P.S. If you click on the link and scroll _all_ the way down the page, you can see the Experts answers ;-)
Thanks for the mail.

I issued following commands

cd /usr2
pax -r < /dev/rct0  - rct0 is my tape device.

Data restored to original location and not to /usr2/..... as I wanted

Am I missing something
Avatar of tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am using SCO Unix Open Server version 5.0.1

/usr1 is a separate file system and I can mount and dismount the system.

I was considering the alternate you suggested about the quite time if other solutions did not work.

Thanks for the help

Krishna Murthi