LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 09:56 AM   #1
threezerous
Member
 
Registered: Jul 2009
Posts: 96

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

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

Original Poster
Rep: Reputation: 16
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, 11:03 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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, 02:20 PM   #5
threezerous
Member
 
Registered: Jul 2009
Posts: 96

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


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

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

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