LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 12-14-2003, 10:40 AM   #1
everythingand2
Member
 
Registered: Oct 2003
Location: Kansas City, MO
Distribution: Slackware 9.1
Posts: 61

Rep: Reputation: 15
Tar including all parent directories?


I'm using the following command to tar an entire directory containing other directories and files...

tar -cvp /usr/local/mysql/data/ > /usr/local/backups/mysqlbackups.tar

but when I untar the file it has included the directories /usr/local/mysql/data as well a the files within the data directory. How do I tar just the files and directories within the data directory and exclude all the parent directories leading up to it?

Thanks.
 
Old 12-14-2003, 11:09 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 253Reputation: 253Reputation: 253
tar -cp --file=/usr/local/backups/mysqlbackups.tar /usr/local/mysql/data/*

That should work and how I usually tar up a particular directory and its files, not sure why your using the > in your tar command.
 
Old 12-14-2003, 05:37 PM   #3
everythingand2
Member
 
Registered: Oct 2003
Location: Kansas City, MO
Distribution: Slackware 9.1
Posts: 61

Original Poster
Rep: Reputation: 15
hmm...

that still included all the parent directories.

Is there a way just to tar the data directory and that's it? The parent directories are empty but I still have to go through all of them to get to the data directory.
 
Old 12-14-2003, 06:24 PM   #4
Faecal
Member
 
Registered: Sep 2002
Location: York, UK
Distribution: Debian Sid
Posts: 215

Rep: Reputation: 30
Paths are stored in a tarball relative to where you were when you issued the command to create it.

Code:
tar -cvpf /usr/local/backups/mysqlbackups.tar /usr/local/mysql/data/
Is problematic, but
Code:
cd /usr/local/mysql/
tar -cvpf /usr/local/backups/mysqlbackups.tar data/
will give you an archive that outputs a "data" directory.
 
Old 12-14-2003, 06:31 PM   #5
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Try:

tar cpf mysqlbackups.tar -C /usr/local/mysql/ data

As Faecal says, it's probably easier to cd into the directory first.

Lyle
 
  


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 won't exclude directories. yougene Slackware 9 12-01-2005 09:32 AM
Exclude directories when backing up with 'tar'? wolfpeach Linux - Newbie 2 06-28-2004 10:54 AM
Make tar of most recent directories drlaz Linux - Newbie 1 06-22-2004 06:38 PM
Including other directories g++ & gtk The Yeti Lives Linux - Newbie 2 06-11-2003 08:21 PM
tar multiple directories computera Linux - General 2 11-17-2001 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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