Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix command line arguments for duplicity 2.1 #2301

Merged
merged 3 commits into from Sep 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 36 additions & 14 deletions management/backup.py
Expand Up @@ -57,10 +57,11 @@ def parse_line(line):
"/usr/bin/duplicity",
"collection-status",
"--archive-dir", backup_cache_dir,
"--gpg-options", "--cipher-algo=AES256",
"--gpg-options", "'--cipher-algo=AES256'",
"--log-fd", "1",
get_duplicity_target_url(config),
] + get_duplicity_additional_args(env),
] + get_duplicity_additional_args(env) + [
get_duplicity_target_url(config)
],
get_duplicity_env_vars(env),
trap=True)
if code != 0:
Expand Down Expand Up @@ -227,8 +228,8 @@ def get_duplicity_additional_args(env):
port = 22

return [
f"--ssh-options= -i /root/.ssh/id_rsa_miab -p {port}",
f"--rsync-options= -e \"/usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p {port} -i /root/.ssh/id_rsa_miab\"",
f"--ssh-options='-i /root/.ssh/id_rsa_miab -p {port}'",
f"--rsync-options='-e \"/usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p {port} -i /root/.ssh/id_rsa_miab\"'",
]
elif get_target_type(config) == 's3':
# See note about hostname in get_duplicity_target_url.
Expand Down Expand Up @@ -321,11 +322,12 @@ def service_command(service, command, quit=None):
"--archive-dir", backup_cache_dir,
"--exclude", backup_root,
"--volsize", "250",
"--gpg-options", "--cipher-algo=AES256",
"--gpg-options", "'--cipher-algo=AES256'",
"--allow-source-mismatch"
] + get_duplicity_additional_args(env) + [
env["STORAGE_ROOT"],
get_duplicity_target_url(config),
"--allow-source-mismatch"
] + get_duplicity_additional_args(env),
],
get_duplicity_env_vars(env))
finally:
# Start services again.
Expand All @@ -343,8 +345,9 @@ def service_command(service, command, quit=None):
"--verbosity", "error",
"--archive-dir", backup_cache_dir,
"--force",
] + get_duplicity_additional_args(env) + [
get_duplicity_target_url(config)
] + get_duplicity_additional_args(env),
],
get_duplicity_env_vars(env))

# From duplicity's manual:
Expand All @@ -358,8 +361,9 @@ def service_command(service, command, quit=None):
"--verbosity", "error",
"--archive-dir", backup_cache_dir,
"--force",
] + get_duplicity_additional_args(env) + [
get_duplicity_target_url(config)
] + get_duplicity_additional_args(env),
],
get_duplicity_env_vars(env))

# Change ownership of backups to the user-data user, so that the after-bcakup
Expand Down Expand Up @@ -396,9 +400,10 @@ def run_duplicity_verification():
"--compare-data",
"--archive-dir", backup_cache_dir,
"--exclude", backup_root,
] + get_duplicity_additional_args(env) + [
get_duplicity_target_url(config),
env["STORAGE_ROOT"],
] + get_duplicity_additional_args(env), get_duplicity_env_vars(env))
], get_duplicity_env_vars(env))

def run_duplicity_restore(args):
env = load_environment()
Expand All @@ -408,9 +413,23 @@ def run_duplicity_restore(args):
"/usr/bin/duplicity",
"restore",
"--archive-dir", backup_cache_dir,
get_duplicity_target_url(config),
] + get_duplicity_additional_args(env) + args,
get_duplicity_env_vars(env))
] + get_duplicity_additional_args(env) + [
get_duplicity_target_url(config)
] + args,
get_duplicity_env_vars(env))

def print_duplicity_command():
import shlex
env = load_environment()
config = get_backup_config(env)
backup_cache_dir = os.path.join(env["STORAGE_ROOT"], 'backup', 'cache')
for k, v in get_duplicity_env_vars(env).items():
print(f"export {k}={shlex.quote(v)}")
print("duplicity", "{command}", shlex.join([
"--archive-dir", backup_cache_dir,
] + get_duplicity_additional_args(env) + [
get_duplicity_target_url(config)
]))

def list_target_files(config):
import urllib.parse
Expand Down Expand Up @@ -618,6 +637,9 @@ def write_backup_config(env, newconfig):
# to duplicity. The restore path should be specified.
run_duplicity_restore(sys.argv[2:])

elif sys.argv[-1] == "--duplicity-command":
print_duplicity_command()

else:
# Perform a backup. Add --full to force a full backup rather than
# possibly performing an incremental backup.
Expand Down