bin/pvl.backup-rsync
changeset 70 3b1290aeed12
parent 67 91153d8b499c
child 73 6cff0468e572
--- a/bin/pvl.backup-rsync	Sat Feb 16 21:41:42 2013 +0200
+++ b/bin/pvl.backup-rsync	Sat Feb 16 21:42:10 2013 +0200
@@ -50,23 +50,26 @@
 
     #
     parser.add_option('-c', '--command',    metavar='CMD', default=os.environ.get('SSH_ORIGINAL_COMMAND'),
-            help="rsync command to execute")
+            help="Rsync command to execute")
 
     parser.add_option('-C', '--given-command', action='store_true', default=False,
-            help="use given command in `rsync -e '%prog -C --' ...` format")
+            help="Use given command in `rsync -e '%prog -C --' ...` format")
 
     parser.add_option('-n', '--noop', action='store_true', default=False,
             help="Parse command, but do not execute")
 
     parser.add_option('-R', '--readonly',   action='store_true', default=False,
-            help="restrict to read/source mode")
+            help="Restrict to read/source mode")
 
     parser.add_option('-P', '--restrict-path', metavar='PATH', action='append',
-            help="restrict to given path prefix")
+            help="Restrict to given path prefix")
 
     parser.add_option('--allow-remote',     action='store_true', default=False,
             help="Allow remote rsync sources")
 
+    parser.add_option('--sudo',             action='store_true',
+            help="Execute rsync under sudo")
+
     # lvm options
     parser.add_option('-L', '--snapshot-size', metavar='SIZE', default=lvm.LVM_SNAPSHOT_SIZE,
             help="create snapshot with given LV size (used to store writes during backup)")
@@ -130,6 +133,7 @@
                 restrict_paths      = options.restrict_path,
                 allow_remote        = options.allow_remote,
                 lvm_opts            = dict(
+                    sudo    = options.sudo,
                     size    = options.snapshot_size, 
                     wait    = options.snapshot_wait,
                     retry   = options.snapshot_retry,
@@ -148,7 +152,9 @@
     # execute
     try :
         # run rsync within the source (may perform additional stuff like snapshot...)
-        source.execute(rsync_options, srcdst)
+        source.execute(rsync_options, srcdst,
+                sudo        = options.sudo,
+        )
 
     except InvokeError, e:
         log.error("%s failed: %d", e.cmd, e.exit)