8 |
8 |
9 sudo PYTHONPATH=. ./bin/pvl.backup-rsync --command 'rsync --server --sender -ax . lvm:asdf:test' -vD |
9 sudo PYTHONPATH=. ./bin/pvl.backup-rsync --command 'rsync --server --sender -ax . lvm:asdf:test' -vD |
10 |
10 |
11 sudo sh -c "PYTHONPATH=. rsync -e './bin/pvl.backup-rsync --debug -C --' -ax testing:lvm:asdf:test test/tmp" |
11 sudo sh -c "PYTHONPATH=. rsync -e './bin/pvl.backup-rsync --debug -C --' -ax testing:lvm:asdf:test test/tmp" |
12 """ |
12 """ |
|
13 |
|
14 import pvl.args |
13 |
15 |
14 from pvl.backup import __version__ |
16 from pvl.backup import __version__ |
15 from pvl.backup.rsync import RSyncCommandFormatError |
17 from pvl.backup.rsync import RSyncCommandFormatError |
16 from pvl.backup.invoke import InvokeError |
18 from pvl.backup.invoke import InvokeError |
17 from pvl.backup import rsync, lvm |
19 from pvl.backup import rsync, lvm |
37 description = __doc__, |
39 description = __doc__, |
38 version = __version__, |
40 version = __version__, |
39 ) |
41 ) |
40 |
42 |
41 # logging |
43 # logging |
42 general = optparse.OptionGroup(parser, "General Options") |
44 parser.add_option_group(pvl.args.parser(parser)) |
43 |
|
44 general.add_option('-q', '--quiet', dest='loglevel', action='store_const', const=logging.WARNING, help="Less output") |
|
45 general.add_option('-v', '--verbose', dest='loglevel', action='store_const', const=logging.INFO, help="More output") |
|
46 general.add_option('-D', '--debug', dest='loglevel', action='store_const', const=logging.DEBUG, help="Even more output") |
|
47 general.add_option('--debug-for', action='append', metavar='MODULE', help="Enable logging for the given logger/module name") |
|
48 |
|
49 parser.add_option_group(general) |
|
50 |
45 |
51 # |
46 # |
52 parser.add_option('-c', '--command', metavar='CMD', default=os.environ.get('SSH_ORIGINAL_COMMAND'), |
47 parser.add_option('-c', '--command', metavar='CMD', default=os.environ.get('SSH_ORIGINAL_COMMAND'), |
53 help="Rsync command to execute") |
48 help="Rsync command to execute") |
54 |
49 |
80 parser.add_option('--snapshot-retry', metavar='RETRY', default=lvm.LVM_SNAPSHOT_RETRY, type='int', |
75 parser.add_option('--snapshot-retry', metavar='RETRY', default=lvm.LVM_SNAPSHOT_RETRY, type='int', |
81 help="retry snapshot removal by given iterations") |
76 help="retry snapshot removal by given iterations") |
82 |
77 |
83 # defaults |
78 # defaults |
84 parser.set_defaults( |
79 parser.set_defaults( |
85 debug_for = [], |
|
86 loglevel = logging.INFO, |
|
87 |
|
88 restrict_path = [], |
80 restrict_path = [], |
89 ) |
81 ) |
90 |
82 |
91 # parse |
83 # parse |
92 options, args = parser.parse_args(argv[1:]) |
84 options, args = parser.parse_args(argv[1:]) |
93 |
85 |
94 # configure |
86 # general logging/etc |
95 logging.basicConfig( |
87 pvl.args.apply(options) |
96 format = argv[0] + ': %(levelname)6s %(name)s : %(funcName)s : %(message)s', |
|
97 level = options.loglevel, |
|
98 ) |
|
99 |
|
100 # enable debugging for specific targets |
|
101 for target in options.debug_for : |
|
102 logging.getLogger(target).setLevel(logging.DEBUG) |
|
103 |
88 |
104 return options, args |
89 return options, args |
105 |
90 |
106 def rsync_wrapper (options, command, local=False) : |
91 def rsync_wrapper (options, command, local=False) : |
107 """ |
92 """ |