1758266 Members
2862 Online
108868 Solutions
New Discussion юеВ

restoring tar backup

 
Sajith P V
Advisor

restoring tar backup

Hi all,

I have a tar backup in tape. I want exclude some files and directories while restoring the tar backup. I cannot find a command for the same in the net. Expecting some gud solution from you people.


Sajith
10 REPLIES 10
Hasan  Atasoy
Honored Contributor

Re: restoring tar backup

hi ;

assuming tar file is in the tape ( /dev/rmt/omn )

tar xvf /dev/rmt/0mn /path_of_the file


eg. you want to restore /tmp/myfile on the tape

then
tar xvf /dev/rmt/omn/ /tmp/myfile,

you can look at tape archive list by

tar tvf /dev/rmt/omn

Hasan
Dennis Handly
Acclaimed Contributor

Re: restoring tar backup

There really isn't any good way to exclude things with tar(1). You can include complete directory trees and try to skip the ones you don't want.
You could also list all of the files you want to restore by using "tv" as Hasan mentioned.

You could also use pax(1) to read your tarfile. It has a -c option to exclude patterns.
Steven Schweda
Honored Contributor

Re: restoring tar backup

> I cannot find a command for the same in the
> net.

"man tar" would be my first resource.

> You could also use pax(1) [...]

Or GNU "tar":

[...]
--exclude=pattern
--exclude-from=file
[...]

http://www.gnu.org/software/tar/
http://www.gnu.org/software/tar/manual/
Sajith P V
Advisor

Re: restoring tar backup

Can any one tell me the syntax of pax command to exclude the file while restoring?.....

Sajith
Dennis Handly
Acclaimed Contributor

Re: restoring tar backup

Here is pax(1) for 11.31:
http://docs.hp.com/en/B2355-60130/pax.1.html

You need:
$ pax -r -f /dev/rmt/0mn -c pattern ...

You can leave out the "-r" (for read) to see if your exclude patterns are correct.
john korterman
Honored Contributor

Re: restoring tar backup

Hi Sajith,

you could perhaps use the -w option for tar, e.g.:
# tar -xvwf /dev/whatever/..

regards,
John K.
it would be nice if you always got a second chance
Dennis Handly
Acclaimed Contributor

Re: restoring tar backup

>John: you could perhaps use the -w option for tar

That might work. But you may have to have a file with the appropriate number "y" and "n" to match which file is being restored. And would tar read from stdin?
john korterman
Honored Contributor

Re: restoring tar backup

Hi again,

the -w option on the command line causes tar to prompt the user for each file in the archive.
(although I would have expected an -i option for something like that)


regards,
John K.
it would be nice if you always got a second chance
Sajith P V
Advisor

Re: restoring tar backup

hi,
my tar backup contains a lot of files and directories. I don't think it is possible to type n and y for these much files..

Sajith