]> arthur.barton.de Git - bup.git/blob - cmd/drecurse-cmd.py
74249c993b8be352525131faa150f6024a053e82
[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 comma-seperated list of paths to exclude from the backup
10 q,quiet  don't actually print filenames
11 profile  run under the python profiler
12 """
13 o = options.Options('bup drecurse', optspec)
14 (opt, flags, extra) = o.parse(sys.argv[1:])
15
16 if len(extra) != 1:
17     o.fatal("exactly one filename expected")
18
19 if opt.exclude:
20     excluded_paths = [realpath(x) for x in opt.exclude.split(",")]
21 else:
22     excluded_paths = None
23
24 it = drecurse.recursive_dirlist(extra, opt.xdev, excluded_paths)
25 if opt.profile:
26     import cProfile
27     def do_it():
28         for i in it:
29             pass
30     cProfile.run('do_it()')
31 else:
32     if opt.quiet:
33         for i in it:
34             pass
35     else:
36         for (name,st) in it:
37             print name
38
39 if saved_errors:
40     log('WARNING: %d errors encountered.\n' % len(saved_errors))
41     sys.exit(1)