LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-14-2009, 06:24 PM   #1
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Rep: Reputation: 15
Post 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
 
Old 10-14-2009, 08:18 PM   #2
tERn
LQ Newbie
 
Registered: Jun 2008
Distribution: Ubuntu (Fluxbox)
Posts: 28

Rep: Reputation: 16
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
 
Old 10-14-2009, 08:31 PM   #3
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by dnaqvi View Post
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)
 
Old 10-15-2009, 12:47 PM   #4
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
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
 
Old 10-15-2009, 01:26 PM   #5
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
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

Last edited by smeezekitty; 10-15-2009 at 01:27 PM.
 
Old 10-15-2009, 04:12 PM   #6
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
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
 
Old 10-15-2009, 04:53 PM   #7
tERn
LQ Newbie
 
Registered: Jun 2008
Distribution: Ubuntu (Fluxbox)
Posts: 28

Rep: Reputation: 16
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

Last edited by tERn; 10-15-2009 at 05:15 PM. Reason: correction
 
Old 10-15-2009, 06:11 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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.
 
Old 10-15-2009, 11:49 PM   #9
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by dnaqvi View Post
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.
 
Old 10-21-2009, 11:25 AM   #10
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by lutusp View Post
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?
 
Old 10-21-2009, 08:24 PM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
See my post #8; default for tar is to strip leading '/'.
 
Old 10-22-2009, 05:51 PM   #12
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
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.
 
Old 10-22-2009, 05:55 PM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
Extract specific directory / file from tar ust Linux - Newbie 3 09-11-2008 01:15 AM
How to extract specific directory from a TAR file? Micro420 Linux - General 4 04-18-2007 12:04 AM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 03:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration