1832757 Members
3186 Online
110045 Solutions
New Discussion

tar restore

 
SOLVED
Go to solution
A.G.M. Velthof
Valued Contributor

tar restore

Hello all,

I want to do a restore of multiple files from a tarfile.
I cannot use wildcards *, so how can I restore all files in the tar file starting with say 040505?
Perhaps with some kind of script?

Thanks in advance, Alfons
6 REPLIES 6
Joseph Loo
Honored Contributor

Re: tar restore

hi,

try this at the directory where you want to "untar":
# tar -xwf

the "w" option causes an interactive tar session in which you are asked to confirm restore for each file with either a "y" or "n". Slow but safe.

regards.
what you do not see does not mean you should not believe
A.G.M. Velthof
Valued Contributor

Re: tar restore

Hello Joseph,

Because the archive contains thousands of little files and I need twenty of them your solution does not work for me.

Greetings, Alfons
Sanjay_6
Honored Contributor
Solution

Re: tar restore

Hi,

Try this,

tar tf /dev/rmt/0m | grep 040505 | xargs tar xvf /dev/rmt/0m

This will restore all files that has 040505 anywhere within the name of the file or the directory. You can try with grep "/040505" and it might help in extracting only files and directories starting with 040505.

Hope this helps.

Regds

Mark Grant
Honored Contributor

Re: tar restore

This might be a little low tech but if you know the names of the twenty you need

tar xvf /dev/whatever file1 file2 file3 ...
Never preceed any demonstration with anything more predictive than "watch this"
A.G.M. Velthof
Valued Contributor

Re: tar restore

Hello Sanjaj,

it works fine, thanks.

Greetings, Alfons
Francisco J. Soler
Honored Contributor

Re: tar restore

Hi Alfons,

If you have all files inside a directory tree, you can restore it with:

tar xvf device directory_name

if not, you can list all files from the tape in a text file, then recover only what you want:

tar tf device > list_tar.txt

once you have list_tar.txt you can do:

cat list_tar.txt | grep 040505| xargs tar xvf device

The xargs is mandatory because it is possible to have a very long list of files and obtain a wrong number of arguments error.

Frank.
Linux?. Yes, of course.