mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-24 02:37:05 +00:00
Simplify duplicity command line by omitting rsync options if the backup target type is not rsync
This commit is contained in:
parent
9004bb6e8e
commit
8bebaf6a48
@ -14,11 +14,6 @@ from exclusiveprocess import Lock
|
|||||||
|
|
||||||
from utils import load_environment, shell, wait_for_service, fix_boto
|
from utils import load_environment, shell, wait_for_service, fix_boto
|
||||||
|
|
||||||
rsync_ssh_options = [
|
|
||||||
"--ssh-options= -i /root/.ssh/id_rsa_miab",
|
|
||||||
"--rsync-options= -e \"/usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p 22 -i /root/.ssh/id_rsa_miab\"",
|
|
||||||
]
|
|
||||||
|
|
||||||
def backup_status(env):
|
def backup_status(env):
|
||||||
# If backups are dissbled, return no status.
|
# If backups are dissbled, return no status.
|
||||||
config = get_backup_config(env)
|
config = get_backup_config(env)
|
||||||
@ -65,8 +60,8 @@ def backup_status(env):
|
|||||||
"--gpg-options", "--cipher-algo=AES256",
|
"--gpg-options", "--cipher-algo=AES256",
|
||||||
"--log-fd", "1",
|
"--log-fd", "1",
|
||||||
config["target"],
|
config["target"],
|
||||||
] + rsync_ssh_options,
|
] + get_duplicity_additional_args(env),
|
||||||
get_env(env),
|
get_duplicity_env_vars(env),
|
||||||
trap=True)
|
trap=True)
|
||||||
if code != 0:
|
if code != 0:
|
||||||
# Command failed. This is likely due to an improperly configured remote
|
# Command failed. This is likely due to an improperly configured remote
|
||||||
@ -195,7 +190,16 @@ def get_passphrase(env):
|
|||||||
|
|
||||||
return passphrase
|
return passphrase
|
||||||
|
|
||||||
def get_env(env):
|
def get_duplicity_additional_args(env):
|
||||||
|
config = get_backup_config(env)
|
||||||
|
if get_target_type(config) == 'rsync':
|
||||||
|
return [
|
||||||
|
"--ssh-options= -i /root/.ssh/id_rsa_miab",
|
||||||
|
"--rsync-options= -e \"/usr/bin/ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p 22 -i /root/.ssh/id_rsa_miab\"",
|
||||||
|
]
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_duplicity_env_vars(env):
|
||||||
config = get_backup_config(env)
|
config = get_backup_config(env)
|
||||||
|
|
||||||
env = { "PASSPHRASE" : get_passphrase(env) }
|
env = { "PASSPHRASE" : get_passphrase(env) }
|
||||||
@ -275,8 +279,8 @@ def perform_backup(full_backup):
|
|||||||
env["STORAGE_ROOT"],
|
env["STORAGE_ROOT"],
|
||||||
config["target"],
|
config["target"],
|
||||||
"--allow-source-mismatch"
|
"--allow-source-mismatch"
|
||||||
] + rsync_ssh_options,
|
] + get_duplicity_additional_args(env),
|
||||||
get_env(env))
|
get_duplicity_env_vars(env))
|
||||||
finally:
|
finally:
|
||||||
# Start services again.
|
# Start services again.
|
||||||
service_command("dovecot", "start", quit=False)
|
service_command("dovecot", "start", quit=False)
|
||||||
@ -293,8 +297,8 @@ def perform_backup(full_backup):
|
|||||||
"--archive-dir", backup_cache_dir,
|
"--archive-dir", backup_cache_dir,
|
||||||
"--force",
|
"--force",
|
||||||
config["target"]
|
config["target"]
|
||||||
] + rsync_ssh_options,
|
] + get_duplicity_additional_args(env),
|
||||||
get_env(env))
|
get_duplicity_env_vars(env))
|
||||||
|
|
||||||
# From duplicity's manual:
|
# From duplicity's manual:
|
||||||
# "This should only be necessary after a duplicity session fails or is
|
# "This should only be necessary after a duplicity session fails or is
|
||||||
@ -308,8 +312,8 @@ def perform_backup(full_backup):
|
|||||||
"--archive-dir", backup_cache_dir,
|
"--archive-dir", backup_cache_dir,
|
||||||
"--force",
|
"--force",
|
||||||
config["target"]
|
config["target"]
|
||||||
] + rsync_ssh_options,
|
] + get_duplicity_additional_args(env),
|
||||||
get_env(env))
|
get_duplicity_env_vars(env))
|
||||||
|
|
||||||
# Change ownership of backups to the user-data user, so that the after-bcakup
|
# Change ownership of backups to the user-data user, so that the after-bcakup
|
||||||
# script can access them.
|
# script can access them.
|
||||||
@ -347,7 +351,7 @@ def run_duplicity_verification():
|
|||||||
"--exclude", backup_root,
|
"--exclude", backup_root,
|
||||||
config["target"],
|
config["target"],
|
||||||
env["STORAGE_ROOT"],
|
env["STORAGE_ROOT"],
|
||||||
] + rsync_ssh_options, get_env(env))
|
] + get_duplicity_additional_args(env), get_duplicity_env_vars(env))
|
||||||
|
|
||||||
def run_duplicity_restore(args):
|
def run_duplicity_restore(args):
|
||||||
env = load_environment()
|
env = load_environment()
|
||||||
@ -358,8 +362,8 @@ def run_duplicity_restore(args):
|
|||||||
"restore",
|
"restore",
|
||||||
"--archive-dir", backup_cache_dir,
|
"--archive-dir", backup_cache_dir,
|
||||||
config["target"],
|
config["target"],
|
||||||
] + rsync_ssh_options + args,
|
] + get_duplicity_additional_args(env) + args,
|
||||||
get_env(env))
|
get_duplicity_env_vars(env))
|
||||||
|
|
||||||
def list_target_files(config):
|
def list_target_files(config):
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
Loading…
Reference in New Issue
Block a user