Operating System - HP-UX
1831927 Members
3532 Online
110031 Solutions
New Discussion

Restoring selected files from TAR

 
SAMIR SHAH_1
Contributor

Restoring selected files from TAR

How to restore selected files with the help of tar command.

I want to restore those files which has extension of .dbf.

I tried with "tar -xvf /dev/rmt/0m /data/*.dbf

It did not do anything.

Pl. help.

Thanks.
4 REPLIES 4
rajsri
Frequent Advisor

Re: Restoring selected files from TAR

hi samir
tar doesnt allow wild card usage .

better to use fbackup its very efficient .
Bruce Regittko_1
Esteemed Contributor

Re: Restoring selected files from TAR

Hi,

The * on the command line is special to the shell, not tar. The shell will attempt to substitute file names that match the pattern /data/*.pdf, where the * can be 0 or more characters.

Since tar does not recognize wild cards, you will have to get creative. Try something like tar xf /dev/rmt/0m $( tar tf /dev/rmt/0m | grep "/data/*.pdf" ). Good luck,

--Bruce
www.stratech.com/training
Insu Kim
Honored Contributor

Re: Restoring selected files from TAR

You have to specify full filename when you use tar in order to retrieve certain file.
Do not use wild charactor!

Regards,
Never say "no" first.
Dan Hetzel
Honored Contributor

Re: Restoring selected files from TAR

Hi Samir,

Bruce's method looks pretty but could give you an "argument list too long error message", depending on the number of /data/*.dbf files.

In that case, you may use a temp file:
tar tf /dev/rmt/0m | grep "/data/*.dbf" >/tmp/tar$$
cat /tmp/tar$$ | xargs tar xf /dev/rmt/0m

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com