[NTLUG:Discuss] tar --exclude doesn't

Courtney Grimland cgrimland at yahoo.com
Tue Sep 30 17:59:13 CDT 2003


Using GNU tar version 1.13...

I am trying to do a system backup, and want to exclude the contents
of a few dirs, like /home/* and /usr/src/*.  I still want the /home
and /usr/src directories in the archive, but not their contents.

For the life of me, I cannot get the --exclude option of tar to work
as advertised.

Here's an example - what am I doing wrong?

[root at jupiter /tmp]# ls -l *
one:
total 0
-rw-r--r--    1 root     root            0 Sep 30 17:46 one
-rw-r--r--    1 root     root            0 Sep 30 17:46 three
-rw-r--r--    1 root     root            0 Sep 30 17:46 two

three:
total 0
-rw-r--r--    1 root     root            0 Sep 30 17:47 one
-rw-r--r--    1 root     root            0 Sep 30 17:47 three
-rw-r--r--    1 root     root            0 Sep 30 17:47 two

two:
total 0
-rw-r--r--    1 root     root            0 Sep 30 17:46 one
-rw-r--r--    1 root     root            0 Sep 30 17:46 three
-rw-r--r--    1 root     root            0 Sep 30 17:46 two

[root at jupiter /tmp]# tar -c --exclude=one/* -f test.tar ./
[root at jupiter /tmp]# tar -tf test.tar | grep one/
one/
one/one
one/two
one/three



For the record, I've tried all of the following:

tar -cv --exclude="one/*" -f test.tar ./
tar -cv --exclude='one/*' -f test.tar ./
tar -cv --exclude one/* -f test.tar ./
tar -cv --exclude "one/*" -f test.tar ./
tar -cv --exclude 'one/*' -f test.tar ./

I've also tried moving the options around (the -f test.tar before the
--exclude, etc), as well as the --exclude-from=FILE option,
specifying a file with the same globbing patterns.  All with the same
results.  I know I've done this before, but apparently I'm missing
something now.

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com



More information about the Discuss mailing list