[CentOS] tar exclude question

Charles Polisher cpolish at surewest.net
Thu Mar 17 14:55:23 UTC 2011


Rainer Traut wrote:
> Nico Kadel-Garcia:
> > Rainer Traut<tr.ml at gmx.de>  wrote:
> >> 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
> >
> > Try this:
> >
> >       20 23 * * *     tar -zcf
> > /mnt/backupInternalHosts/backup/backup.tar.gz -C / etc root/home&&
> > touch /tmp/state_backup-backup
> 
> Hmm, I already did?
> tar -zc -f /mnt/backupInternalHosts/backup/backup.tar.gz -C / etc root
> home && touch /tmp/state_backup-backup
> 
> But the problem with it is, as soon as you use excludes this can be 
> dangerous because they can match everywhere in your backup path.

Check out the GNU Tar Reference manual, much more informative
than "man tar". Look for CACHEDIR.TAG and --exclude-caches, works
very well for me. The CACHEDIR.TAG file is added to any directory
you want to skip, and tar will skip it. Here's the contents:

$ cat /var/cache/CACHEDIR.TAG
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by (application name).
# For information about cache directory tags, see:
#       http://www.brynosaurus.com/cachedir/

-- 
Charles Polisher



More information about the CentOS mailing list