LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-17-2004, 02:23 AM   #1
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
tar, excluding directories recursively


hey all

I have tried man and info for tar, as well as google
and this site, but just cant find what i need.

I want to make a tar and exclude 2 directory
trees recursively. Everything i've seen says to use
--exclude, but that doesn't seem to work for me.
Anyway, doesn't that option only work with patterns?
And isn't it impossible to express a dir tree recursively
thru a pattern?

Also have the option to make a big exclude list, but
these are directories with many small files, and that
seems like a big waste of power.

Here is a link to the script i'm trying to use, everything
works except that tar won't excluded the directory trees:
http://galaxy.lamar.edu/~ja137401/lq/backup

Thanks in advance
 
Old 06-17-2004, 08:52 AM   #2
arobic
Member
 
Registered: Jul 2003
Location: Geneva, Switzerland
Distribution: Debian 3.1, SLC3 (based on RHEL)
Posts: 84

Rep: Reputation: 15
Hi!

From what I understood, if you want to exclude directories recursively from tar, the command --exclude should work fine! Even if you can only use patterns and not regexp, you can still make it do what you want (from what I know!)

So , to use --exclude, here is the syntax:

tar -cf tarball.tar --exclude=pattern filelist

so maybe just rewriting
tarOptions="-c -P --preserve --exclude /home/justin/archive/mysql/manual/ /home/justin/archive/php/ -f

to be:
tarOptions="-c -P --preserve --exclude=home/justin/archive/mysql/manual --exclude=home/justin/archive/php -f

and execute it from the / directory would work.

This will exclude everything in /home/justin/archive/mysql/manual recursively.

Hope this will help you! I still have a lot to learn, so tell me if this doesn't work!!
 
Old 06-17-2004, 09:21 AM   #3
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Original Poster
Rep: Reputation: 15
thanks arobic!

I will try this tonite.
 
Old 06-17-2004, 12:32 PM   #4
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Original Poster
Rep: Reputation: 15
many thanks, arobic!

this worked with the following modification: added * to the end of the pattern,
so it reads like this:

Code:
tarOptions="-c -P --preserve --exclude=/home/justin/archive/mysql/manual/* --exclude=/home/justin/archive/php/* -f"
reduced the tar file to 32% of its previous size with only 12% the number of files!

if anyone is interested, the new script can be found here:
http://galaxy.lamar.edu/~ja137401/backupScript/backup

Thanks again
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
excluding directories from commands David the H. Linux - General 5 04-06-2009 03:21 PM
Remove directories recursively with same name cboyd Linux - Newbie 5 01-14-2007 09:48 PM
Find excluding multiple directories with a wildcard pteigeler Linux - Software 1 09-02-2005 10:57 AM
Excluding directories from zip files jonathanztaub Linux - General 1 05-17-2004 02:17 AM
tar and excluding files murshed Linux - Newbie 7 03-15-2003 02:32 PM

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

All times are GMT -5. The time now is 01:33 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