LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-05-2006, 03:30 AM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
tar exclude from not working


I'm using GNU/tar & trying to exclude a directory which is not working. Here are the various switches I tried -

tar -cjvf back.full.tar.bz2 / --exclude-from='/tmp/*'

tar -cjvf back.full.tar.bz2 / --exclude-from='/tmp/'

tar -cjvf back.full.tar.bz2 / --exclude=/tmp/*

none of them work.

The directory I am trying to exclude is /tmp. It doesn't have sub-directories.
 
Old 08-05-2006, 04:16 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,

I do believe you are using the wrong option.

You are using:

--exclude-from=FILE (exclude patterns listed in FILE), but you are giving it a pattern, not a file with entries that tar should exclude.

If you want to give the file/dir to exclude directly to tar use:
--exclude=PATTERN (exclude files, given as a PATTERN).

Something like this should work:

tar -cjvf back.full.tar.bz2 / --exclude=/tmp*

Hope this helps.
 
Old 08-05-2006, 06:05 PM   #3
noir911
Member
 
Registered: Apr 2004
Posts: 682

Original Poster
Rep: Reputation: Disabled
I tried the exact same command but it doesn't work. I also tried to put "/tmp*" and "/tmp/*" (without quotes) in a file and did -

tar -cjvf back.full.tar.bz2 / --exclude=file

doesn't work.

I am using Fedora Core 5's gnu/tar as root.
 
Old 08-05-2006, 06:37 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,

The command you are using is incorrect:

tar -cjvf back.full.tar.bz2 / --exclude-from=file

If file is filled with:
/tmp
It should be excluded from the archive.
 
Old 08-05-2006, 06:43 PM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
tar -cjvf back.full.tar.bz2 --exclude="/tmp" /


is what I think you are after
 
Old 08-05-2006, 07:05 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Tar works for me using either method.
For example:

# ls Music
mp3 files wav files
Code:
(cd /home ; tar -cvf /mnt/backup/my_backup.tar --exclude wav\ files Music)
or
(cd /home ; tar -cvf /mnt/backup/my_backup.tar --exclude "wav files" Music)

### Second method
# create a file with list of directories and/or files to be excluded.
find Music -type d -name 'wav\ files' > file.txt

(cd /home ; tar -cvf /mnt/backup/my_backup.tar -X file.txt Music)
 
  


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 won't exclude directories. yougene Slackware 9 12-01-2005 09:32 AM
tar --exclude --exclude-from cefn Linux - Software 4 10-11-2005 07:31 PM
tar --exclude-from=FILE GATTACA Programming 1 07-29-2005 12:25 PM
tar exclude-from drisay Slackware 1 12-23-2004 01:10 PM
tar --exclude for subdirectories mrtwice Linux - Software 2 10-23-2003 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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