System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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...

Steven Schweda
Honored Contributor

Re: Restore a entire directory using tar command

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


   Just another (old) GNU "tar":

$ uname -a
Darwin appleq2 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh


$ tar --version
tar (GNU tar) 1.15.1

 

(An OS version newer than 10.5.8 may include a newer "tar", of course,
but I tend to live in the past with my old junk collection.)

James R. Ferguson
Acclaimed Contributor

Re: Restore a entire directory using tar command


Steven Schweda wrote:

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


   Just another (old) GNU "tar":

$ uname -a
Darwin appleq2 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh


$ tar --version
tar (GNU tar) 1.15.1

 

(An OS version newer than 10.5.8 may include a newer "tar", of course,
but I tend to live in the past with my old junk collection.)


Well, for the sake of interest, it looks like this:

 

$ uname -a
Darwin JRFs-iMac.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386

 

$ tar --version
bsdtar 2.6.2 - libarchive 2.6.2

...so here's another variant.

 

Regards!

 

...JRF...

Dennis Handly
Acclaimed Contributor

Re: Restore a entire directory using tar command

>In an HP-UX environment, in my opinion, it is a superior replacement to 'tar'.

 

It has to be, since pax is the "replacement" for fbackup/frecover.  ;-)

James R. Ferguson
Acclaimed Contributor
Solution

Re: Restore a entire directory using tar command


Dennis Handly wrote:

>In an HP-UX environment, in my opinion, it is a superior replacement to 'tar'.

 

It has to be, since pax is the "replacement" for fbackup/frecover.  ;-)


Indeed, that's the hope :-)  I have not played with the graph ability of 'pax' either.

 

Regards!

 

...JRF...

member_unix
Senior Member

Re: Restore a entire directory using tar command

Thanks to all forum members to help, support and guidance.