LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Get specific file from tar (https://www.linuxquestions.org/questions/linux-newbie-8/get-specific-file-from-tar-761942/)

dnaqvi 10-14-2009 06:24 PM

Get specific file from tar
 
Hello ALl,

I am doing TAR backup for our Portal Application.

I used following command to do TAR backup.

tar -cvf tstname.tar /home/portal/you

Now I need to recover only one specific file from the TAR.

for instead I have file called tset3 under home/portal/you.

I wanted to untar or recover only test3.

Please advice. thanks

tERn 10-14-2009 08:18 PM

Hi

I believe dar is the application that you are looking for. I have not used it before so I cannot tell you for sure. Go here and look at the section "direct access" http://dar.linux.free.fr/doc/Features.html

I hope this helps.
Cheerz

lutusp 10-14-2009 08:31 PM

Quote:

Originally Posted by dnaqvi (Post 3719514)
Hello ALl,

I am doing TAR backup for our Portal Application.

I used following command to do TAR backup.

tar -cvf tstname.tar /home/portal/you

Now I need to recover only one specific file from the TAR.

for instead I have file called tset3 under home/portal/you.

I wanted to untar or recover only test3.

Please advice. thanks

Simple:

Code:

$ tar -xf tstname.tar (desired file path and name)

dnaqvi 10-15-2009 12:47 PM

Not found in archive
 
tar xf testbk.tar /opt/IBM/test
tar: /opt/IBM/test: Not found in archive
tar: Error exit delayed from previous errors

smeezekitty 10-15-2009 01:26 PM

try this
Code:

tar xf testbk.tar -C /opt/IBM/test
----edit----
unless /opt/IBM/test is the filename in that case
it must not be in the archive

dnaqvi 10-15-2009 04:12 PM

tar: Error is not recoverable: exiting now
 
tar xf testbk.tar -C /opt/IBM/test
tar: /opt/IBM/test: Cannot chdir: Not a directory
tar: Error is not recoverable: exiting now

tERn 10-15-2009 04:53 PM

Hi

If:
If you find tar to be fast enough for you, then ignore me.

Else:
make a dar archive
Code:

dar -c <archive_name> -y -s <size> -R <path>
-s - size of slices
-y enable bz2 compression

Extract single file:
Code:

dar -x <archive_name> --go-into <path>
<path> is the path of the file you want to extract.

PS. If you made your archive with archive name "backup" use "backup" also as archive name in extraction and not not the spesific slices that dar has made.

Here is a link if you want more help
http://dar.linux.free.fr/doc/mini-ho...-howto.en.html

Greetings

chrism01 10-15-2009 06:11 PM

Quote:

-P, --absolute-names
don't strip leading '/'s from file names
http://linux.die.net/man/1/tar

If you didn't use this option during tar create, it will have stripped 1st/leading '/' from each filepath, so that you can re-locate the files during extracts.
To see what you've actually got, try

tar -tvf blah.tar

and go from there.

lutusp 10-15-2009 11:49 PM

Quote:

Originally Posted by dnaqvi (Post 3720555)
tar xf testbk.tar /opt/IBM/test
tar: /opt/IBM/test: Not found in archive
tar: Error exit delayed from previous errors

So your specified path isn't present in the archive. You can't magically make it part of your archive. In order for this method to work, you have to specify a path that is actually in the archive.

dnaqvi 10-21-2009 11:25 AM

Quote:

Originally Posted by lutusp (Post 3721184)
So your specified path isn't present in the archive. You can't magically make it part of your archive. In order for this method to work, you have to specify a path that is actually in the archive.

Path is exist.

I did the tar as below

tar -cvf testbk.tar /opt

I have a file called "test" exist under /opt/IBM

I need to retrieve only test file

How do you retrieve?

chrism01 10-21-2009 08:24 PM

See my post #8; default for tar is to strip leading '/'.

dnaqvi 10-22-2009 05:51 PM

If I do tar -tvf testbk.tar this it will untar all files.

We have 20GB TAR backup.

We do not want top open every single directory or file.

We want to run the script to open only one file from the TAR backup.

chrism01 10-22-2009 05:55 PM

No it doesn't; read the link I gave you. -t lists the table of contents.


All times are GMT -5. The time now is 06:43 AM.