1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-26 02:57:04 +00:00

rsync backup broke other things

This commit is contained in:
Joshua Tauberer 2016-11-12 09:58:49 -05:00
parent abb6a1a070
commit 96b3a29800
2 changed files with 12 additions and 10 deletions

View File

@ -13,6 +13,11 @@ import rtyaml
from utils import exclusive_process, load_environment, shell, wait_for_service, fix_boto 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): def backup_status(env):
# Root folder # Root folder
backup_root = os.path.join(env["STORAGE_ROOT"], 'backup') backup_root = os.path.join(env["STORAGE_ROOT"], 'backup')
@ -30,11 +35,6 @@ def backup_status(env):
backups = { } backups = { }
backup_cache_dir = os.path.join(backup_root, 'cache') 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): def reldate(date, ref, clip):
if ref < date: return clip if ref < date: return clip
rd = dateutil.relativedelta.relativedelta(ref, date) rd = dateutil.relativedelta.relativedelta(ref, date)
@ -410,10 +410,12 @@ def list_target_files(config):
code, listing = shell('check_output', rsync_command, trap=True) code, listing = shell('check_output', rsync_command, trap=True)
if code == 0: if code == 0:
ret = []
for l in listing.split('\n'): for l in listing.split('\n'):
match = rsync_fn_size_re.match(l) match = rsync_fn_size_re.match(l)
if match: if match:
yield (match.groups()[1], int(match.groups()[0].replace(',',''))) ret.append( (match.groups()[1], int(match.groups()[0].replace(',',''))) )
return ret
else: else:
raise ValueError("Connection to rsync host failed") raise ValueError("Connection to rsync host failed")

View File

@ -225,10 +225,10 @@ function show_custom_backup() {
} else if (r.target.substring(0, 8) == "rsync://") { } else if (r.target.substring(0, 8) == "rsync://") {
$("#backup-target-type").val("rsync"); $("#backup-target-type").val("rsync");
var path = r.target.substring(8).split('//'); var path = r.target.substring(8).split('//');
var [ user, host ] = path.shift().split('@'); var host_parts = path.shift().split('@');
$("#backup-target-rsync-user").val(user); $("#backup-target-rsync-user").val(host_parts[0]);
$("#backup-target-rsync-host").val(host); $("#backup-target-rsync-host").val(host_parts[1]);
$("#backup-target-rsync-path").val('/'+path); $("#backup-target-rsync-path").val('/'+path[0]);
} else if (r.target.substring(0, 5) == "s3://") { } else if (r.target.substring(0, 5) == "s3://") {
$("#backup-target-type").val("s3"); $("#backup-target-type").val("s3");
var hostpath = r.target.substring(5).split('/'); var hostpath = r.target.substring(5).split('/');