LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar, excluding directories recursively (https://www.linuxquestions.org/questions/linux-newbie-8/tar-excluding-directories-recursively-194476/)

towlie 06-17-2004 02:23 AM

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

arobic 06-17-2004 08:52 AM

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!!

towlie 06-17-2004 09:21 AM

thanks arobic!

I will try this tonite.

towlie 06-17-2004 12:32 PM

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


All times are GMT -5. The time now is 11:19 AM.