bup index \<-p|-m|-s|-u|\--clear|\--check\> [-H] [-l] [-x] [\--fake-valid]
[\--no-check-device] [\--fake-invalid] [-f *indexfile*] [\--exclude *path*]
[\--exclude-from *filename*] [\--exclude-rx *pattern*]
-[\--exclude-rx-from *filename*] [-v] \<filenames...\>
+[\--exclude-rx-from *filename*] [\--exclude-caches] [-v] \<filenames...\>
# DESCRIPTION
: read --exclude-rx patterns from *filename*, one pattern per-line
(may be repeated). Ignore completely empty lines.
+
+\--exclude-caches
+: exclude all directories that contain a file CACHEDIR.TAG, whose
+ content begins with "Signature: 8a477f597d28d172789f06886806bc55".
+ For more information on cachedir-tagging, see
+ http://www.brynosaurus.com/cachedir/
+
\--no-check-device
: don't mark a an entry invalid if the device number (stat(2)
st_dev) changes. This can be useful when indexing remote,
t/test-ls.sh \
t/test-meta.sh \
t/test-on.sh \
+ t/test-index-excludes.sh \
t/test-restore-map-owner.sh \
t/test-restore-single-file.sh \
t/test-rm-between-index-and-save.sh \
for (path,pst) in drecurse.recursive_dirlist([top], xdev=opt.xdev,
bup_dir=bup_dir,
excluded_paths=excluded_paths,
- exclude_rxs=exclude_rxs):
+ exclude_rxs=exclude_rxs,
+ exclude_caches=opt.exclude_caches):
if opt.verbose>=2 or (opt.verbose==1 and stat.S_ISDIR(pst.st_mode)):
sys.stdout.write('%s\n' % path)
sys.stdout.flush()
exclude-from= skip --exclude paths in file (may be repeated)
exclude-rx= skip paths matching the unanchored regex (may be repeated)
exclude-rx-from= skip --exclude-rx patterns in file (may be repeated)
+exclude-caches exclude CACHEDIR.TAG-directories
v,verbose increase log output (can be used more than once)
x,xdev,one-file-system don't cross filesystem boundaries
"""
def _recursive_dirlist(prepend, xdev, bup_dir=None,
excluded_paths=None,
- exclude_rxs=None):
+ exclude_rxs=None,
+ exclude_caches=None):
for (name,pst) in _dirlist():
path = prepend + name
if excluded_paths:
if exclude_rxs and should_rx_exclude_path(path, exclude_rxs):
continue
if name.endswith('/'):
+ if exclude_caches:
+ tag_filename = 'CACHEDIR.TAG'
+ tag_contents = 'Signature: 8a477f597d28d172789f06886806bc55'
+ if os.path.exists(prepend+name+tag_filename):
+ f = open(prepend+name+tag_filename, 'rb')
+ data = f.read(len(tag_contents))
+ f.close()
+ if data == tag_contents:
+ debug1('Skipping %r: excluding cache dir' % (prepend+name))
+ continue
if bup_dir != None:
if os.path.normpath(path) == bup_dir:
debug1('Skipping BUP_DIR.\n')
for i in _recursive_dirlist(prepend=prepend+name, xdev=xdev,
bup_dir=bup_dir,
excluded_paths=excluded_paths,
- exclude_rxs=exclude_rxs):
+ exclude_rxs=exclude_rxs,
+ exclude_caches=exclude_caches):
yield i
os.chdir('..')
yield (path, pst)
def recursive_dirlist(paths, xdev, bup_dir=None, excluded_paths=None,
- exclude_rxs=None):
+ exclude_rxs=None,
+ exclude_caches=None):
startdir = OsFile('.')
try:
assert(type(paths) != type(''))
for i in _recursive_dirlist(prepend=prepend, xdev=xdev,
bup_dir=bup_dir,
excluded_paths=excluded_paths,
- exclude_rxs=exclude_rxs):
+ exclude_rxs=exclude_rxs,
+ exclude_caches=exclude_caches):
yield i
startdir.fchdir()
else:
--- /dev/null
+#!/usr/bin/env bash
+. ./wvtest-bup.sh
+. t/lib.sh
+
+top="$(pwd)"
+bup() { "$top/bup" "$@"; }
+
+WVSTART "exclude-caches"
+(
+ set -e -o pipefail
+ D="$(wvmktempdir)"
+ force-delete $D
+ mkdir $D
+ export BUP_DIR="$D/.bup"
+ WVPASS bup init
+ touch $D/a
+ WVPASS bup random 128k >$D/b
+ mkdir $D/d $D/d/e
+ WVPASS bup random 512 >$D/f
+ echo 'Signature: 8a477f597d28d172789f06886806bc55' > $D/d/CACHEDIR.TAG
+ WVPASS bup index -ux --exclude-caches $D
+ bup save -n exclude $D
+ WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
+b
+f"
+) || WVFAIL