Operating System - HP-UX
1829648 Members
9714 Online
109992 Solutions
New Discussion

Re: Restoring tape using tar

 
SOLVED
Go to solution
Henry_52
Advisor

Restoring tape using tar

Hi,

I took backup using tar

$tar -cvf /dev/rmt/0m /oracle

Now I have new directory /test. And I want to restore my backup into /test.
I have run tar xvf /dev/rmt/0m /test
or tar xvf /dev/rmt/0m .
But it is not working. It is not
doing anything , not restoring.

If I do "tar xvf /dev/rmt/0m /oracle , than it's start restoring backup but in to /oracle.

How can I restore backup into other directory ?

Thank you.

Henry
7 REPLIES 7
Sundar_7
Honored Contributor
Solution

Re: Restoring tape using tar

Henry,

With tar, if you use the absolute path name to backup the file, then you can only restore it to the absolute path.

You will have to use pax to restore it to a relative path

# cd /test
# pax -rf /dev/rmt/0m -s '|^/|\./|'

the above command will restore the files from the tape relative to the /test directory

-- Sundar.
Learn What to do ,How to do and more importantly When to do ?
john kingsley
Honored Contributor

Re: Restoring tape using tar

HP's tar doesn't have an option to restore the directory as something else.
Try this:
cd /
tar -cvf /dev/rmt/0m ./oracle
cd /test
tar -xvf /dev/rmt/0m
This will put the data in /test/oracle
Jason_216
Occasional Advisor

Re: Restoring tape using tar

tar is not a good command in HP UX,

u can use the both fbackup and frecover command in HP unix

to backup
# fbackup -f /dev/rmt/0m -i /oracle

to restore everything back to /oracle
# frecover -f /dev/rmt/0m -r


but if u still want to use tar
# tar -xvf /dev/rmt/0m ./oracle

Muthukumar_5
Honored Contributor

Re: Restoring tape using tar

You have taken archieve as absolute path /oracle/*

When if you try to extract then it will do it exactly /oracle/

You can change that as,
cd /;
tar -cvf /dev/rmt/0m oracle

or
tar -cvf /dev/rmt/0m ./oracle

To extract under /test then,
mkdir /test
cd /test
tar -xvf /dev/rmt/0m

It will now extract as /test/oracle/*

Easy to suggest when don't know about the problem!
Sยภเl Kย๓คг
Respected Contributor

Re: Restoring tape using tar

Yes this is the way

#tar -cvf /dev/rmt/0m ./oracle
#cd /test
#tar -xvf /dev/rmt/0m

regards
SK
Your imagination is the preview of your life's coming attractions
RAC_1
Honored Contributor

Re: Restoring tape using tar

The tar backups taken with absolute paths will be restored to original path. The tar can not exclude / in tar archive.

You can try as follows.

1. Use of pax
cd /where_to_resore
pax -rv -s '/^\///' < your.tar

2. Use GNU tar.
Take care of block size.

3. Use of chroot environment
/usr/bin/cp /usr/sbin/static/tar /tmp
/usr/bin/dd if=file.tar | /usr/bin/chroot /tmp ./tar xf -

Anil
There is no substitute to HARDWORK
Henry_52
Advisor

Re: Restoring tape using tar

Thank you for your quick reply.
Because I can't backup again,
I have to restore tar tapes.
According to Sundar's reply,
I could restore tapes using pax command.
Thank you very much Sundar !!!

Henry