Operating System - HP-UX
1753770 Members
5280 Online
108799 Solutions
New Discussion

Restore a entire directory using tar command

 
SOLVED
Go to solution
member_unix
Senior Member

Restore a entire directory using tar command

Hi All,

 

Can anyone help me to provide the syntax to restore a directory from tape archive? I am able to restore entire tape and didn't find a correct command to restore a directory. below is the option I already tried. The directory I am trying to restore from tape is alreay created with the same name.

 

cd /

 

tar xvphf /dev/rmt/1m   <directory name to restore>

tar xvphf /dev/rmt /1m  "directory name to restore"

 

Please help

14 REPLIES 14
Steven Schweda
Honored Contributor

Re: Restore a entire directory using tar command

> Can anyone help me [...]

   It might be easier for us non-psychics to help if you showed us (a
relevant part of) a listing of what's on the tape, and revealed what,
exactly, you want to extract from the tape.


      tar tfv [...]

> [...] <directory name to restore>
> [...] "directory name to restore"

   Hiding potentially important details may not be the best way to get
accurate answers.

   Also normally interesting:

      uname -a

member_unix
Senior Member

Re: Restore a entire directory using tar command

Operating System.

 

HP-UX  B.10.20 

 

Here is what I get

 

tar -vxt /dev/rmt/1m

 

rwxrwx---   0/101  53066 May  8 00:54 1999 ./symix27/symix/dc/menu-r.r

rwxrwx---   0/101  81766 May  8 00:54 1999 ./symix27/symix/dc/mir.r

rwxrwx---   0/101  52291 May  8 00:54 1999 ./symix27/symix/dc/mmenu-r.r

.....

..... 

so...on

 

there is a directory in the system... by the name.

/dev/vg01/symix    3053521       9 2748159    0% /symix27

 

 and I want to restore entire contents of /symix27 from tape archive to sytem directory name symix27.

 

please help to set the command to restore a directory using tar

 

Thanks,

member_unix
Senior Member

Re: Restore a entire directory using tar command

typo error

 

I used this command to get the list in archive tape

 

tar -tvf /dev/rmt/1m

Steven Schweda
Honored Contributor

Re: Restore a entire directory using tar command

> [...]
> rwxrwx---   0/101  53066 May  8 00:54 1999 ./symix27/symix/dc/menu-r.r#
> [...]

   A name which you specify must match the name in the archive.  If the
names in the archive are "./symix27/[...]", then you should probably
specify the thing to extract as "./symix27".  You should be able to test
this:

      tar -tvf /dev/rmt/1m ./symix27

If that shows you the right files, then, assuming that all those other
options are what you want, I'd try:

      tar xvphf /dev/rmt /1m ./symix27

   Because the names in the archive are relative ("./", which is
normally a good thing), you do need to do that "cd /", as you showed
before, if you want "./symix27" to go into "/symix27".

Dennis Handly
Acclaimed Contributor

Re: Restore a entire directory using tar command

>You should be able to test this: tar -tvf /dev/rmt/1m ./symix27

 

HP's tar doesn't take a file with -t.  But pax does:  (Perhaps GNU tar too?)

pax -tvf /dev/rmt/1m ./symix27

Steven Schweda
Honored Contributor

Re: Restore a entire directory using tar command

> HP's tar doesn't take a file with -t.

   Hmmm.  Trust no one, I always say.  But, ooh.  That's pretty lame.
Even the (pretty lame) VMSTAR on VMS does that.  My brain is probably
tuned for Zip+UnZip these days, and, of course, "unzip -t" does it, too.
(It's not a good excuse, but it's the best I can do.)

>   But pax does:  (Perhaps GNU tar too?)

   GNU "tar" does, too.  (Of course.)

James R. Ferguson
Acclaimed Contributor

Re: Restore a entire directory using tar command


@Steven Schweda wrote:

> HP's tar doesn't take a file with -t.

   Hmmm.  Trust no one, I always say.  But, ooh.  That's pretty lame.


>   But pax does:  (Perhaps GNU tar too?)

   GNU "tar" does, too.  (Of course.)


HP should get with the program and look at the wealth of features GNU tools bring :-)

 

Personally, I have grown quite fond of 'pax'.  In an HP-UX environment, in my opinion, it is a superior replacement to 'tar'.

 

Regards!

 

...JRF...

Steven Schweda
Honored Contributor

Re: Restore a entire directory using tar command

   For those keeping score, AIX /usr/bin/tar, Solaris /usr/sbin/tar, and
Tru64 /sbin/tar also do it.  (Perhaps my brain is not quite so weak as I
had feared.)

James R. Ferguson
Acclaimed Contributor

Re: Restore a entire directory using tar command


@Steven Schweda wrote:

   For those keeping score, AIX /usr/bin/tar, Solaris /usr/sbin/tar, and
Tru64 /sbin/tar also do it.  (Perhaps my brain is not quite so weak as I
had feared.)


Yes, and score one more for Apple Max OS X.

 

Regards!

 

...JRF...