1748153 Members
3767 Online
108758 Solutions
New Discussion юеВ

tar !!!

 
SOLVED
Go to solution
gany59
Regular Advisor

tar !!!

how to use the tar command to restore the specific file to the specified target location

Thanks in advance.....
7 REPLIES 7
cnb
Honored Contributor

Re: tar !!!

Use the x (extract) qualifier.


http://docs.hp.com/en/B2355-90690/tar.1.html

See the examples in the manpage.


Rgds,


Bill Hassell
Honored Contributor
Solution

Re: tar !!!

I think there is a more complicated question here. tar on HP-UX does not have a destination override for recovered files and directories. So if the original tar file or tape has / as the first character in the pathname, all the files you select will go right back to the exact same directory. That's why it is recommended to always leave off the first / when making a backup.

Use tar tvf to read the table of contents, at least a portion, so you can see how the files were saved. If the files have been saved with a leading /, this is called an absolute pathname and you'll have to use chroot to recover the files into a different directory structure.


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: tar !!!

Hi:

> Bill: If the files have been saved with a leading /, this is called an absolute pathname and you'll have to use chroot to recover the files into a different directory structure.

Or use 'pax'. See the manpages.

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: tar !!!

> Or use 'pax'. See the manpages.

Or use GNU "tar".

http://www.gnu.org/software/tar/
http://www.gnu.org/software/tar/manual/index.html


> I think there is a more complicated
> question here. [...]

There might be one somewhere, but it's not
here. As usual, it can be easier to give a
useful answer when the question contains some
useful information.
chris huys_4
Honored Contributor

Re: tar !!!

or use pax. ;)

example.

topaz:/dumps_10/pt_1204197284_chrishu # tar -tvf crash1.tar
rwxr-xr-x 0/0 0 Jun 8 15:20 2004 /var/adm/crash/crash.1/
rw-r--r-- 0/0 7300414 Jun 8 15:19 2004 /var/adm/crash/crash.1/vmunix.gz
[..]

Tar backup is taken with absolute path.

Contents of the tar archive needs to be restored relatively, to the directory /dumps_10/pt_1204197284_chrishu/ .

topaz:/dumps_10/pt_1204197284_chrishu # pax -r -f ./crash1.tar -s!/var/adm/crash/!./!gp -t
/var/adm/crash/crash.1/ >> ./crash.1/
/var/adm/crash/crash.1/vmunix.gz >> ./crash.1/vmunix.gz
/var/adm/crash/crash.1/image.1.1.gz >> ./crash.1/image.1.1.gz
/var/adm/crash/crash.1/image.1.2.gz >> ./crash.1/image.1.2.gz
/var/adm/crash/crash.1/image.1.3.gz >> ./crash.1/image.1.3.gz
/var/adm/crash/crash.1/image.1.4.gz >> ./crash.1/image.1.4.gz
/var/adm/crash/crash.1/image.1.5.gz >> ./crash.1/image.1.5.gz
/var/adm/crash/crash.1/image.1.6.gz >> ./crash.1/image.1.6.gz
/var/adm/crash/crash.1/image.1.7.gz >> ./crash.1/image.1.7.gz
/var/adm/crash/crash.1/INDEX >> ./crash.1/INDEX

topaz:/dumps_10/pt_1204197284_chrishu # cd crash.1

topaz:/dumps_10/pt_1204197284_chrishu/crash.1 # ll
total 104808
-rw-r--r-- 1 root sys 1225 Jun 8 15:20 INDEX
-rw-r--r-- 1 root sys 1252299 Jun 8 15:19 image.1.1.gz
-rw-r--r-- 1 root sys 1378576 Jun 8 15:20 image.1.2.gz
-rw-r--r-- 1 root sys 1438041 Jun 8 15:20 image.1.3.gz
-rw-r--r-- 1 root sys 1245761 Jun 8 15:20 image.1.4.gz
-rw-r--r-- 1 root sys 3595650 Jun 8 15:20 image.1.5.gz
-rw-r--r-- 1 root sys 16923559 Jun 8 15:20 image.1.6.gz
-rw-r--r-- 1 root sys 20516167 Jun 8 15:20 image.1.7.gz


But I agree, with the general remark, that most forumusers, asking a question, completely forget vital information, when asking a question, leaving the ones who respond, to guess, at what the real problem is...

To understand a question, normally the following info is needed..
>>>>>>
Operating System Version --
Hardware Model --

Problem Description (oneliner) --

Details --
;osversion;

storage :

Background question --

>>>>>>>

Greetz,
Chris
S.N.S
Valued Contributor

Re: tar !!!

Gany, as Chris says - to get what you want, you need to give what we need...

Ask a comprehensive question with crisp details - only then you would get crisp answers...Help Us and ofcourse yourself...

Anyways, a small eg --
if you wanted to copy /etc/lvmtab from the
tape /dev/rmt/0mn in IA64 using the default tar
simply -

tar xvf /dev/rmt/0mn etc/lvmtab

Note "/" is absent before etc

It copies to the dir you are in.

You can follow the same syntax as per your need...

And Points pls! :-) It makes us all happier to help

HTH
SNS
"Genius is 1% inspiration, 99% Perspiration" - Edison
gany59
Regular Advisor

Re: tar !!!

Thanks folks ... really u people helped a lot

I am closing this thread