Operating System - HP-UX
1822439 Members
2741 Online
109642 Solutions
New Discussion юеВ

Re: How to un-TAR to a particular dir.

 
SOLVED
Go to solution
Shahbaz_1
Regular Advisor

How to un-TAR to a particular dir.

Hi Friends,
I have created a tar in a tape of the following two dirs

/u01/prod/data
/u02/prod/data

Now when I am going to un-TAR it to another server, Do I need to have /u01/prod/data and /u20 dir or the un-TAR will create?
And can I un-TAR it to /u01/prod/prodata
and /u02/prod/proddata ?

Another question is from the TAR, can I get a particular file?

Thanks in Adv

Regards
Shah
Let's share the great thing "THE KNOWLEDGE"
5 REPLIES 5
steven Burgess_2
Honored Contributor
Solution

Re: How to un-TAR to a particular dir.

Shah

You will not be able to untar your files to another directory as it looks as though you created your archive using the absolute pathnames. This means the files will be restored to their original locations. If you are restoring to the same paths then you shouldn't have a problem

To get a particular file

tar xvf .tar

HTH

Steve
take your time and think things through
Michael Tully
Honored Contributor

Re: How to un-TAR to a particular dir.

Hi,

If the directory doesn't exist, it will get created from the tar extraction, tar xvf .....

Yes you can extract one file at a time if you wish.

e.g.

# tar xvf /dev/rmt/0m /u02/prod/prodata/mydatafile

One piece of advice, when you create a tar archive from / always use ./u02 to do your backups not /u02
From this you can extract into any other named filesystem or directory.

e.g.

# cd /
# tar cvf ./u02 ./u03

Have a look at the man page which also has some other suggestions.

Michael
Anyone for a Mutiny ?
steven Burgess_2
Honored Contributor

Re: How to un-TAR to a particular dir.

Shah

To create your tar files with relative path names , first cd the directory then create you tar file

cd

tar cvf /dev/rmt/0m

That way when you wish to restore your archive you can go to whatever directory you wish and untar your file

HTH

Steve
take your time and think things through
Shahbaz_1
Regular Advisor

Re: How to un-TAR to a particular dir.

Thanks, for your quick and great response.


Regards
Shah
Let's share the great thing "THE KNOWLEDGE"
Olav Baadsvik
Esteemed Contributor

Re: How to un-TAR to a particular dir.


Hi,

Actually there is a way to restore to
a different directory even if the tape was
made using absolute path:

1- Logon as root
2- cd to directory : cd /newdir
3- cp tar over : cp /sbin/tar /newdir
4- make sure about tar owner and group : chown bin:bin tar
5- make the tapedevicefile example : mknod 0m c 212 0x010000
(or just cp /dev/rmt/0m /newdir)
6- chroot /newdir tar xvf 0m
will copy all files and the directory structure to /newdir

Regards
Olav