LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   exclude nested folder from tar (https://www.linuxquestions.org/questions/linux-newbie-8/exclude-nested-folder-from-tar-4175521778/)

threezerous 10-11-2014 09:56 AM

exclude nested folder from tar
 
I am obviosuly missing something in this simple command, but have spent quite a while trying different combinations. Please advise if you can find the error I am missing.

Code:

tar cvzf squidanalyzer-6.0.tgz --exclude=./squidanalyzer-6.0/etc/log/* squidanalyzer-6.0/
The output keeps including the files under /etc/log

squidanalyzer-6.0/etc/
squidanalyzer-6.0/etc/excluded
squidanalyzer-6.0/etc/included
squidanalyzer-6.0/etc/squidanalyzer.conf
squidanalyzer-6.0/etc/network-aliases
squidanalyzer-6.0/etc/log/
squidanalyzer-6.0/etc/log/access_log
squidanalyzer-6.0/etc/log/access_log-20140914
squidanalyzer-6.0/etc/log/error_log-20140921
squidanalyzer-6.0/etc/log/error_log-20140914
squidanalyzer-6.0/etc/log/error_log-20140928
squidanalyzer-6.0/etc/log/access_log-20140907
squidanalyzer-6.0/etc/log/access_log-20140923
squidanalyzer-6.0/etc/log/error_log-20141005
squidanalyzer-6.0/etc/log/error_log
squidanalyzer-6.0/etc/user-aliases
squidanalyzer-6.0/Makefile
squidanalyzer-6.0/ChangeLog

I tried other permutations of the exclude pattern as
Code:

tar -cvzf squidanalyzer-6.0.tgz --exclude='./squidanalyzer-6.0/etc/log/*' squidanalyzer-6.0

tar -cvzf squidanalyzer-6.0.tgz --exclude='./squidanalyzer-6.0/etc/log' squidanalyzer-6.0

tar --exclude='./squidanalyzer-6.0/etc/log/*' -cvzf squidanalyzer-6.0.tgz squidanalyzer-6.0

tar -cvzf squidanalyzer-6.0.tgz squidanalyzer-6.0 --exclude=./squidanalyzer-6.0/etc/log/*

tar -cvzf squidanalyzer-6.0.tgz squidanalyzer-6.0 --exclude='./squidanalyzer-6.0/etc/log/*'

tar -cvzf squidanalyzer-6.0.tgz squidanalyzer-6.0 --exclude='./squidanalyzer-6.0/etc/log'

But nothing seems to exclude that folder. This is test run. In my ral implementation, I have thousands of log files under that dir and I really don't want to back them up.

Any guidance/suggestion is greatly appreciated. Thanks !

jdkaye 10-11-2014 10:27 AM

Can you tell us what directory you're in when you run this command.
jdk

threezerous 10-11-2014 10:38 AM

The parent directory of squidanalyzer-6.0

I ran my tar command at
/home/threezerous/ level

So my directory structure looks like

/home/threezerous/squidanalyzer-6.0

/home/threezerous/squidanalyzer-6.0/etc/
/home/threezerous/squidanalyzer-6.0/etc/excluded
/home/threezerous/squidanalyzer-6.0/etc/included
...
...
/home/threezerous/squidanalyzer-6.0/etc/log/access_log
/home/threezerous/squidanalyzer-6.0/etc/log/access_log-20140914
/home/threezerous/squidanalyzer-6.0/etc/log/error_log-20140921
...
...

jpollard 10-11-2014 11:03 AM

You might try dropping the "./" from the exclude line.

Exclusions are done based on string matching... Since the list doesn't inlude the "./" (it is based on "squidanalyzer-6.0/") it won't recognize the equivalence.

threezerous 11-01-2014 02:20 PM

Apologies for the late response. But yes, that solved the issue. Thanks very much


All times are GMT -5. The time now is 08:24 AM.