[CentOS] tar exclude question

Rainer Traut tr.ml at gmx.de
Tue Mar 15 09:25:37 UTC 2011

Hi List,

hope this is not too offtopic, but this bothers me and my backup.

My backups are tar jobs in cron, eg:

20 23 * * *     tar -zcf /mnt/backupInternalHosts/backup/backup.tar.gz 
/etc /root /home && touch /tmp/state_backup-backup

This always sends me an unwanted email with:

tar: Removing leading `/' from member names

I consider this a bug because this informal message is printed to error out?

Ok, I rewrite my tar job to get around this:

tar -zc -f /mnt/backupInternalHosts/backup/backup.tar.gz -C / etc root 
home && touch /tmp/state_backup-backup

Fine this works, but problems arise when I try to exclude things 
(example under /tmp/foo):

$ mkdir dir1 dir2 dir1/dir2
$ touch dir1/dir2/importantFile
$ tar -cvf tarfile.tar --exclude=dir2 -C /tmp/foo/ dir1 dir2

Because the exclude pattern matches under dir1 my important File is not 
backed up. The problem is, I cannot specify the exclude pattern to match 
only /tmp/foo/dir2 , can I?


More information about the CentOS mailing list