From 96b3a2980078ed34e40dbf799175fb26193c1c4c Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sat, 12 Nov 2016 09:58:49 -0500 Subject: [PATCH] rsync backup broke other things --- management/backup.py | 14 ++++++++------ management/templates/system-backup.html | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/management/backup.py b/management/backup.py index c1ba03c5..e93b6fcb 100755 --- a/management/backup.py +++ b/management/backup.py @@ -13,6 +13,11 @@ import rtyaml from utils import exclusive_process, 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): # Root folder backup_root = os.path.join(env["STORAGE_ROOT"], 'backup') @@ -30,11 +35,6 @@ def backup_status(env): backups = { } backup_cache_dir = os.path.join(backup_root, 'cache') - 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 reldate(date, ref, clip): if ref < date: return clip rd = dateutil.relativedelta.relativedelta(ref, date) @@ -410,10 +410,12 @@ def list_target_files(config): code, listing = shell('check_output', rsync_command, trap=True) if code == 0: + ret = [] for l in listing.split('\n'): match = rsync_fn_size_re.match(l) if match: - yield (match.groups()[1], int(match.groups()[0].replace(',',''))) + ret.append( (match.groups()[1], int(match.groups()[0].replace(',',''))) ) + return ret else: raise ValueError("Connection to rsync host failed") diff --git a/management/templates/system-backup.html b/management/templates/system-backup.html index 63a220e8..0ccb4bd6 100644 --- a/management/templates/system-backup.html +++ b/management/templates/system-backup.html @@ -225,10 +225,10 @@ function show_custom_backup() { } else if (r.target.substring(0, 8) == "rsync://") { $("#backup-target-type").val("rsync"); var path = r.target.substring(8).split('//'); - var [ user, host ] = path.shift().split('@'); - $("#backup-target-rsync-user").val(user); - $("#backup-target-rsync-host").val(host); - $("#backup-target-rsync-path").val('/'+path); + var host_parts = path.shift().split('@'); + $("#backup-target-rsync-user").val(host_parts[0]); + $("#backup-target-rsync-host").val(host_parts[1]); + $("#backup-target-rsync-path").val('/'+path[0]); } else if (r.target.substring(0, 5) == "s3://") { $("#backup-target-type").val("s3"); var hostpath = r.target.substring(5).split('/');