diff --git a/management/backup.py b/management/backup.py index 17cc54f6..8f51127d 100755 --- a/management/backup.py +++ b/management/backup.py @@ -25,7 +25,6 @@ def backup_status(env): now = datetime.datetime.now(dateutil.tz.tzlocal()) backups = { } - backup_dir = os.path.join(backup_root, 'encrypted') backup_cache_dir = os.path.join(backup_root, 'cache') def reldate(date, ref, clip): @@ -112,8 +111,6 @@ def backup_status(env): bak["deleted_in"] = deleted_in return { - "directory": backup_dir, - "encpwfile": os.path.join(backup_root, 'secret_key.txt'), "tz": now.tzname(), "backups": backups, } @@ -302,7 +299,7 @@ def run_duplicity_verification(): def backup_set_custom(env, target, target_user, target_pass, min_age): - config = get_backup_config(env) + config = get_backup_config(env, for_save=True) # min_age must be an int if isinstance(min_age, str): @@ -317,14 +314,16 @@ def backup_set_custom(env, target, target_user, target_pass, min_age): return "Updated backup config" -def get_backup_config(env): +def get_backup_config(env, for_save=False): backup_root = os.path.join(env["STORAGE_ROOT"], 'backup') + # Defaults. config = { "min_age_in_days": 3, "target": "file://" + os.path.join(backup_root, 'encrypted'), } + # Merge in anything written to custom.yaml. try: custom_config = rtyaml.load(open(os.path.join(backup_root, 'custom.yaml'))) if not isinstance(custom_config, dict): raise ValueError() # caught below @@ -332,6 +331,14 @@ def get_backup_config(env): except: pass + # When updating config.yaml, don't do any further processing on what we find. + if for_save: + return config + + # helper fields for the admin + config["file_target_directory"] = os.path.join(backup_root, 'encrypted') + config["enc_pw_file"] = os.path.join(backup_root, 'secret_key.txt') + return config def write_backup_config(env, newconfig): diff --git a/management/templates/system-backup.html b/management/templates/system-backup.html index 615ba980..ed9f26f3 100644 --- a/management/templates/system-backup.html +++ b/management/templates/system-backup.html @@ -5,44 +5,50 @@

Backup Status

-

Copying Backup Files

-

The box makes an incremental backup each night. By default the backup is stored on the machine itself, but you can also have it stored on Amazon S3

-

You can also use SFTP (FTP over SSH) to copy files from . These files are encrypted, so they are safe to store anywhere. Copy the encryption password from also but keep it in a safe location.

- -

Backup Configuration

+

Configuration

+
+
+
Backups are stored on this machine’s own hard disk. You are responsible for periodically using SFTP (FTP over SSH) to copy the backup files from to a safe location. These files are encrypted, so they are safe to store anywhere.
+
+
+
+
+
Backups are stored in an Amazon Web Services S3 bucket. You must have an AWS account already.
+
+
-
+
-
- +
+
-
- +
+
@@ -54,9 +60,11 @@
-

Current Backups

+

Copy the encryption password from to a safe and secure location. You will need this file to decrypt backup files.

-

The backup directory currently contains the backups listed below. The total size on disk of the backups is currently .

+

Available Backups

+ +

The backup location currently contains the backups listed below. The total size of the backups is currently .

@@ -72,11 +80,8 @@ function toggle_form() { var target_type = $("#target-type").val(); - if (target_type == 'file') { - $(".form-advanced").hide(); - } else { - $(".form-advanced").show(); - } + $(".backup-target-file, .backup-target-s3").hide(); + $(".backup-target-" + target_type).show(); } function nice_size(bytes) { @@ -104,9 +109,6 @@ function show_system_backup() { "GET", { }, function(r) { - $('#backup-location').text(r.directory); - $('#backup-encpassword-file').text(r.encpwfile); - $('#backup-status tbody').html(""); var total_disk_size = 0; @@ -137,6 +139,7 @@ function show_system_backup() { } function show_custom_backup() { + $(".backup-target-file, .backup-target-s3").hide(); api( "/system/backup/config", "GET", @@ -148,6 +151,8 @@ function show_custom_backup() { $("#target-user").val(r.target_user); $("#target-pass").val(r.target_pass); $("#min-age").val(r.min_age_in_days); + $('#backup-location').text(r.file_target_directory); + $('#backup-encpassword-file').text(r.enc_pw_file); toggle_form() }) }