@@ -57,10 +57,11 @@ def parse_line(line):
5757 "/usr/bin/duplicity" ,
5858 "collection-status" ,
5959 "--archive-dir" , backup_cache_dir ,
60- "--gpg-options" , "--cipher-algo=AES256" ,
60+ "--gpg-options" , "' --cipher-algo=AES256' " ,
6161 "--log-fd" , "1" ,
62- get_duplicity_target_url (config ),
63- ] + get_duplicity_additional_args (env ),
62+ ] + get_duplicity_additional_args (env ) + [
63+ get_duplicity_target_url (config )
64+ ],
6465 get_duplicity_env_vars (env ),
6566 trap = True )
6667 if code != 0 :
@@ -227,8 +228,8 @@ def get_duplicity_additional_args(env):
227228 port = 22
228229
229230 return [
230- f"--ssh-options= -i /root/.ssh/id_rsa_miab -p { port } " ,
231- f"--rsync-options= -e \" /usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p { port } -i /root/.ssh/id_rsa_miab\" " ,
231+ f"--ssh-options=' -i /root/.ssh/id_rsa_miab -p { port } ' " ,
232+ f"--rsync-options=' -e \" /usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p { port } -i /root/.ssh/id_rsa_miab\" ' " ,
232233 ]
233234 elif get_target_type (config ) == 's3' :
234235 # See note about hostname in get_duplicity_target_url.
@@ -321,11 +322,12 @@ def service_command(service, command, quit=None):
321322 "--archive-dir" , backup_cache_dir ,
322323 "--exclude" , backup_root ,
323324 "--volsize" , "250" ,
324- "--gpg-options" , "--cipher-algo=AES256" ,
325+ "--gpg-options" , "'--cipher-algo=AES256'" ,
326+ "--allow-source-mismatch"
327+ ] + get_duplicity_additional_args (env ) + [
325328 env ["STORAGE_ROOT" ],
326329 get_duplicity_target_url (config ),
327- "--allow-source-mismatch"
328- ] + get_duplicity_additional_args (env ),
330+ ],
329331 get_duplicity_env_vars (env ))
330332 finally :
331333 # Start services again.
@@ -343,8 +345,9 @@ def service_command(service, command, quit=None):
343345 "--verbosity" , "error" ,
344346 "--archive-dir" , backup_cache_dir ,
345347 "--force" ,
348+ ] + get_duplicity_additional_args (env ) + [
346349 get_duplicity_target_url (config )
347- ] + get_duplicity_additional_args ( env ) ,
350+ ],
348351 get_duplicity_env_vars (env ))
349352
350353 # From duplicity's manual:
@@ -358,8 +361,9 @@ def service_command(service, command, quit=None):
358361 "--verbosity" , "error" ,
359362 "--archive-dir" , backup_cache_dir ,
360363 "--force" ,
364+ ] + get_duplicity_additional_args (env ) + [
361365 get_duplicity_target_url (config )
362- ] + get_duplicity_additional_args ( env ) ,
366+ ],
363367 get_duplicity_env_vars (env ))
364368
365369 # Change ownership of backups to the user-data user, so that the after-bcakup
@@ -396,9 +400,10 @@ def run_duplicity_verification():
396400 "--compare-data" ,
397401 "--archive-dir" , backup_cache_dir ,
398402 "--exclude" , backup_root ,
403+ ] + get_duplicity_additional_args (env ) + [
399404 get_duplicity_target_url (config ),
400405 env ["STORAGE_ROOT" ],
401- ] + get_duplicity_additional_args ( env ) , get_duplicity_env_vars (env ))
406+ ], get_duplicity_env_vars (env ))
402407
403408def run_duplicity_restore (args ):
404409 env = load_environment ()
@@ -408,9 +413,23 @@ def run_duplicity_restore(args):
408413 "/usr/bin/duplicity" ,
409414 "restore" ,
410415 "--archive-dir" , backup_cache_dir ,
411- get_duplicity_target_url (config ),
412- ] + get_duplicity_additional_args (env ) + args ,
413- get_duplicity_env_vars (env ))
416+ ] + get_duplicity_additional_args (env ) + [
417+ get_duplicity_target_url (config )
418+ ] + args ,
419+ get_duplicity_env_vars (env ))
420+
421+ def print_duplicity_command ():
422+ import shlex
423+ env = load_environment ()
424+ config = get_backup_config (env )
425+ backup_cache_dir = os .path .join (env ["STORAGE_ROOT" ], 'backup' , 'cache' )
426+ for k , v in get_duplicity_env_vars (env ).items ():
427+ print (f"export { k } ={ shlex .quote (v )} " )
428+ print ("duplicity" , "{command}" , shlex .join ([
429+ "--archive-dir" , backup_cache_dir ,
430+ ] + get_duplicity_additional_args (env ) + [
431+ get_duplicity_target_url (config )
432+ ]))
414433
415434def list_target_files (config ):
416435 import urllib .parse
@@ -618,6 +637,9 @@ def write_backup_config(env, newconfig):
618637 # to duplicity. The restore path should be specified.
619638 run_duplicity_restore (sys .argv [2 :])
620639
640+ elif sys .argv [- 1 ] == "--duplicity-command" :
641+ print_duplicity_command ()
642+
621643 else :
622644 # Perform a backup. Add --full to force a full backup rather than
623645 # possibly performing an incremental backup.
0 commit comments