2 from __future__ import absolute_import, print_function
3 from os.path import relpath
6 from bup import options, drecurse
7 from bup.compat import argv_bytes
8 from bup.helpers import log, parse_excludes, parse_rx_excludes, saved_errors
9 from bup.io import byte_stream
15 x,xdev,one-file-system don't cross filesystem boundaries
16 exclude= a path to exclude from the backup (can be used more than once)
17 exclude-from= a file that contains exclude paths (can be used more than once)
18 exclude-rx= skip paths matching the unanchored regex (may be repeated)
19 exclude-rx-from= skip --exclude-rx patterns in file (may be repeated)
20 q,quiet don't actually print filenames
21 profile run under the python profiler
25 o = options.Options(optspec)
26 opt, flags, extra = o.parse_bytes(argv[1:])
29 o.fatal("exactly one filename expected")
31 drecurse_top = argv_bytes(extra[0])
32 excluded_paths = parse_excludes(flags, o.fatal)
33 if not drecurse_top.startswith(b'/'):
34 excluded_paths = [relpath(x) for x in excluded_paths]
35 exclude_rxs = parse_rx_excludes(flags, o.fatal)
36 it = drecurse.recursive_dirlist([drecurse_top], opt.xdev,
37 excluded_paths=excluded_paths,
38 exclude_rxs=exclude_rxs)
44 cProfile.run('do_it()')
51 out = byte_stream(sys.stdout)
53 out.write(name + b'\n')
56 log('WARNING: %d errors encountered.\n' % len(saved_errors))