LinuxQuestions.org
Visit Jeremy's Blog.
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 10-11-2014, 10:56 AM   #1
threezerous
Member
 
Registered: Jul 2009
Posts: 91

Rep: Reputation: 15
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 !
 
Old 10-11-2014, 11:27 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,464

Rep: Reputation: Disabled
Can you tell us what directory you're in when you run this command.
jdk
 
Old 10-11-2014, 11:38 AM   #3
threezerous
Member
 
Registered: Jul 2009
Posts: 91

Original Poster
Rep: Reputation: 15
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
...
...
 
Old 10-11-2014, 12:03 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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.
 
1 members found this post helpful.
Old 11-01-2014, 03:20 PM   #5
threezerous
Member
 
Registered: Jul 2009
Posts: 91

Original Poster
Rep: Reputation: 15
Apologies for the late response. But yes, that solved the issue. Thanks very much
 
  


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
TAR Exclude everything in folder except this folder rationalthinker1 Linux - Newbie 5 04-30-2012 09:20 PM
[SOLVED] tar with --exclude and/or --exclude-from vbekker Linux - Newbie 6 12-09-2010 03:51 AM
TAR: Unpack file, exclude a folder Smeerbalg Linux - Software 1 01-29-2006 08:59 AM
tar --exclude --exclude-from cefn Linux - Software 4 10-11-2005 08:31 PM
tar exclude-from drisay Slackware 1 12-23-2004 02:10 PM


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