LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-17-2007, 08:59 PM   #1
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
How to extract specific directory from a TAR file?


My boss deleted her folder off the server. I make backups so I'm clear, however, I cannot find out how from the MAN pages and Google how to ONLY extract from the tar file her directory. All I can find are how to extract a specific file to an individual directory. Not what I want.

I'm thinking maybe:

Code:
cd /home/theboss
tar -tf /backups/filename.tar.gz | grep /home/theboss | xarg tar -zxf filename.tar.gz
Will this work?

Last edited by Micro420; 04-17-2007 at 09:02 PM.
 
Old 04-17-2007, 09:03 PM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
have you tried using file-roller?
 
Old 04-17-2007, 09:05 PM   #3
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
There is no GUI on this server.

Is this correct?

Code:
cd /home/theboss
tar -zxf /backups/filename.tar.gz /home/theboss
I'm assuming that is:
tar -options <source> <directory-to-extract-from-tar-file>

Last edited by Micro420; 04-17-2007 at 09:07 PM.
 
Old 04-17-2007, 10:18 PM   #4
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Code:
cd /home/theboss
tar -zxf /backups/filename.tar.gz /home/theboss
I think this will give you /home/theboss/home/theboss/..., won't it? I believe that you need to run the extraction from the root directory used for creation of the tar file. IOW, if you were actually IN /home/theboss when you ran tar, then, yes, go to /home/theboss. But, your tar won't actually have anything in it starting with /home/theboss, will it?

If this was a full backup, cd to "/". You can do a sort of trial run by running the following and seeing the full pathnames of what's in tar, if you don't already know.
Code:
oops, deleted see edit below
You can also go to some temporary directory and run your extract to see what gets created under that temp directory.

Edit:
Sorry, that should be:
Code:
tar -ztvf /backups/filename.tar.gz /home/theboss

Last edited by Quakeboy02; 04-17-2007 at 10:33 PM.
 
Old 04-18-2007, 01:04 AM   #5
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
Thanks for the suggestions, Quakeboy02. Unfortunately I have to get the data back up by the morning when my boss returns to the office so I can't test your method. I have the files remotely stored so I decided to just use scp. It should be done in a few hours (1.5GB). I could do a complete untar of the backup, but I don't want to risk it and mess up other files and people's directory by overwriting files. The server is on 24/7 and in use throughout the evening.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tar - extract to different directory hcclnoodles Linux - Newbie 4 03-05-2011 04:47 PM
Is it possible to unpack a *.tar into a specific directory whammack Linux - Software 3 01-29-2007 07:04 PM
tar: how to extract only one directory from a backup guarriman Linux - General 1 01-29-2007 11:35 AM
extract tar.gz file manolakis Linux - Newbie 3 11-13-2006 11:49 AM
How To extract .tar.gz To A Specific Directory? George2 Linux - Software 4 02-18-2006 08:01 AM


All times are GMT -5. The time now is 04:10 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration