LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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-07-2011, 03:56 PM   #1
whycali
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Rep: Reputation: 0
Question tar.bz2 exception to --exclude?


I'm writing a script to backup a joomla site. I'd like to exclude every file EXCEPT the index.html file in the /cache /tmp and /administrator/cache directories, but can't figure out how to do it. Here's my command line:

Code:
tar -cjf test.tar.bz2 joomla_16 joomla_16/cache/index.html joomla_16/cache/index.html joomla_16/administrator/cache/index.html --exclude "cache/*" --exclude "_*" --exclude "administrator/cache/*" --exclude "tmp/*"
This creates the archive, excludes the three directories but does not include the index.html files.

Thanks!

Mike

Last edited by whycali; 04-07-2011 at 03:58 PM.
 
Old 04-07-2011, 04:28 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Well, a simple way would be to add the line

Code:
tar -Ajf test.tar.bz2 /cache/index.html /tmp/index.html /administrator/cache/tmp/index.html
 
Old 04-07-2011, 04:52 PM   #3
whycali
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Original Poster
Rep: Reputation: 0
That makes sense, but I got this error when I tried it:

Code:
tar: Cannot concatenate compressed archives
Try `tar --help' or `tar --usage' for more information.
 
Old 04-08-2011, 01:32 PM   #4
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Ah, okay, what you can do is this (just tried it, so it definitely works... at least on my PC):

Code:
tar -cf test.tar joomla_16 joomla_16/cache/index.html joomla_16/cache/index.html joomla_16/administrator/cache/index.html --exclude "cache/*" --exclude "_*" --exclude "administrator/cache/*" --exclude "tmp/*"
tar -Af test.tar /cache/index.html /tmp/index.html /administrator/cache/tmp/index.html
bzip2 test.tar
This separates the two stages - one creates the test.tar file, the next appends the files you want added to it, and then you compress the completed archive
 
Old 04-08-2011, 06:23 PM   #5
whycali
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Wonderful, thanks for all your help. I'll give it a shot, but wanted to thank you first.

Mike
 
Old 04-09-2011, 04:25 AM   #6
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
If the problem's been solved, it's considered polite to mark the thread as 'SOLVED' (there's a link at the top of the page)

And posting a thank post like you did / clicking the reputation buttons is definitely good kudos, so well done for that :P
 
Old 04-11-2011, 01:39 PM   #7
whycali
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Original Poster
Rep: Reputation: 0
All appears to work correctly, but it's not. When I try to open the tar.bz2 file I get this error:
Code:
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
This happens on the tar -Af phase when we're adding the index.html files. What could be causing this?
 
Old 04-12-2011, 11:02 AM   #8
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
*headslap*

So sorry. -A is appending tar files to an archive, but -r is appending files to the end of an archive. So -A would add two .tar files together, but -r would put the next file into the archive.
 
1 members found this post helpful.
Old 04-12-2011, 11:10 AM   #9
whycali
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Original Poster
Rep: Reputation: 0
[SOLVED] tar.bz2 exception to --exclude?

TYVM! That worked like a charm.... rep+++
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to install tar.gz & tar.bz2 file on Linux min Krishnendu Linux Mint 2 07-16-2009 06:52 AM
tar-command not found while compiling glibc-libidn-2.7.tar.bz2 of lfs6.3 aditya_gpch Linux From Scratch 1 05-13-2008 11:27 PM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
.rpms, .tar.gz, .tgz, .src.rpm, & .tar.bz2 whoots Mandriva 10 10-18-2003 12:08 PM
problem unzipping a tar.bz2 file tar: Error is not recov jyome Linux - Software 4 09-04-2003 01:04 PM

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

All times are GMT -5. The time now is 03:03 PM.

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