bup index \<-p|-m|-s|-u\> [-H] [-l] [-x] [\--fake-valid] [\--no-check-device]
[\--fake-invalid] [\--check] [\--clear] [-f *indexfile*] [\--exclude *path*]
-[\--exclude-from *filename*] [\--exclude-rx *pattern*] [-v] \<filenames...\>
+[\--exclude-from *filename*] [\--exclude-rx *pattern*]
+[\--exclude-rx-from *filename*] [-v] \<filenames...\>
# DESCRIPTION
\--exclude=*path*
: exclude *path* from the backup; bup will not expand *path* in any
- way (can be used more than once).
+ way (may be repeated).
\--exclude-from=*filename*
-: read --exclude paths from *filename*, one path per-line (can be
- used more than once).
+: read --exclude paths from *filename*, one path per-line (may be
+ repeated).
\--exclude-rx=*pattern*
: exclude any path matching *pattern*, which must be a Python regular
will be compared against the full path, without anchoring, so
"x/y" will match "ox/yard" or "box/yards". To exclude the
contents of /tmp, but not the directory itself, use
- "^/tmp/.". (can be specified more than once)
+ "^/tmp/.". (may be repeated)
Examples:
* '/foo/.' - exclude the content of any directory named foo
* '^/tmp/.' - exclude root-level /tmp's content, but not /tmp itself
+\--exclude-rx-from=*filename*
+: read --exclude-rx patterns from *filename*, one pattern per-line
+ (may be repeated).
+
\--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,
fake-valid mark all index entries as up-to-date even if they aren't
fake-invalid mark all index entries as invalid
f,indexfile= the name of the index file (normally BUP_DIR/bupindex)
-exclude= a path to exclude from the backup (can be used more than once)
-exclude-from= a file that contains exclude paths (can be used more than once)
-exclude-rx= skip paths that match the unanchored regular expression
+exclude= a path to exclude from the backup (may be repeated)
+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)
v,verbose increase log output (can be used more than once)
x,xdev,one-file-system don't cross filesystem boundaries
"""
def parse_rx_excludes(options, fatal):
"""Traverse the options and extract all rx excludes, or call
Option.fatal()."""
- rxs = [v for f, v in options if f == '--exclude-rx']
- for i in range(len(rxs)):
- try:
- rxs[i] = re.compile(rxs[i])
- except re.error, ex:
- o.fatal('invalid --exclude-rx pattern (%s):' % (ex, rxs[i]))
- return rxs
+ excluded_patterns = []
+
+ for flag in options:
+ (option, parameter) = flag
+ if option == '--exclude-rx':
+ try:
+ excluded_patterns.append(re.compile(parameter))
+ except re.error, ex:
+ fatal('invalid --exclude-rx pattern (%s): %s' % (parameter, ex))
+ elif option == '--exclude-rx-from':
+ try:
+ f = open(realpath(parameter))
+ except IOError, e:
+ raise fatal("couldn't read %s" % parameter)
+ for pattern in f.readlines():
+ spattern = pattern.rstrip('\n')
+ try:
+ excluded_patterns.append(re.compile(spattern))
+ except re.error, ex:
+ fatal('invalid --exclude-rx pattern (%s): %s' % (spattern, ex))
+ return excluded_patterns
def should_rx_exclude_path(path, exclude_rxs):