]> arthur.barton.de Git - bup.git/blob - cmd/drecurse-cmd.py
f80418592bc0c3f10343551f2467b87870ee3030
[bup.git] / cmd / drecurse-cmd.py
1 #!/usr/bin/env python
2 from bup import options, drecurse
3 from bup.helpers import *
4
5 optspec = """
6 bup drecurse <path>
7 --
8 x,xdev,one-file-system   don't cross filesystem boundaries
9 exclude= a path to exclude from the backup (can be used more than once)
10 exclude-from= a file that contains exclude paths (can be used more than once)
11 q,quiet  don't actually print filenames
12 profile  run under the python profiler
13 """
14 o = options.Options(optspec)
15 (opt, flags, extra) = o.parse(sys.argv[1:])
16
17 if len(extra) != 1:
18     o.fatal("exactly one filename expected")
19
20 excluded_paths = drecurse.parse_excludes(flags)
21
22 it = drecurse.recursive_dirlist(extra, opt.xdev, excluded_paths=excluded_paths)
23 if opt.profile:
24     import cProfile
25     def do_it():
26         for i in it:
27             pass
28     cProfile.run('do_it()')
29 else:
30     if opt.quiet:
31         for i in it:
32             pass
33     else:
34         for (name,st) in it:
35             print name
36
37 if saved_errors:
38     log('WARNING: %d errors encountered.\n' % len(saved_errors))
39     sys.exit(1)