2014-09-01 13:06:38 +00:00
< style >
2014-09-08 20:09:18 +00:00
#backup-status th { text-align: center; }
2014-09-01 13:06:38 +00:00
#backup-status tr.full-backup td { font-weight: bold; }
< / style >
< h2 > Backup Status< / h2 >
2015-07-26 16:25:52 +00:00
< p > 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< / p >
2014-09-08 20:12:31 +00:00
2015-08-09 17:52:24 +00:00
< h3 > Configuration< / h3 >
2015-07-26 16:25:52 +00:00
< form class = "form-horizontal" role = "form" onsubmit = "set_custom_backup(); return false;" >
< div class = "form-group" >
2015-08-09 18:25:26 +00:00
< label for = "backup-target-type" class = "col-sm-2 control-label" > Backup to:< / label >
2015-07-26 16:25:52 +00:00
< div class = "col-sm-2" >
2015-08-09 18:25:26 +00:00
< select class = "form-control" rows = "1" id = "backup-target-type" onchange = "toggle_form()" >
< option value = "local" > {{hostname}}< / option >
2015-07-26 16:25:52 +00:00
< option value = "s3" > Amazon S3< / option >
< / select >
< / div >
< / div >
2015-08-09 18:25:26 +00:00
< div class = "form-group backup-target-local" >
2015-08-09 17:52:24 +00:00
< div class = "col-sm-10 col-sm-offset-2" >
< div > 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 < tt id = "backup-location" > < / tt > to a safe location. These files are encrypted, so they are safe to store anywhere.< / div >
< / div >
< / div >
< div class = "form-group backup-target-s3" >
< div class = "col-sm-10 col-sm-offset-2" >
< div > Backups are stored in an Amazon Web Services S3 bucket. You must have an AWS account already.< / div >
< / div >
< / div >
2015-07-26 16:25:52 +00:00
< div class = "form-group" >
2015-08-09 18:25:26 +00:00
< label for = "min-age" class = "col-sm-2 control-label" > How many days should backups be kept?< / label >
2015-07-26 16:25:52 +00:00
< div class = "col-sm-8" >
2015-08-09 18:25:26 +00:00
< input type = "number" class = "form-control" rows = "1" id = "min-age" >
2015-07-26 16:25:52 +00:00
< / div >
< / div >
2015-08-09 17:52:24 +00:00
< div class = "form-group backup-target-s3" >
2015-08-09 18:25:26 +00:00
< label for = "backup-target-s3-host" class = "col-sm-2 control-label" > S3 Region< / label >
2015-07-26 16:25:52 +00:00
< div class = "col-sm-8" >
2015-08-09 18:25:26 +00:00
< select class = "form-control" rows = "1" id = "backup-target-s3-host" >
{% for name, host in backup_s3_hosts %}
< option value = "{{host}}" > {{name}}< / option >
{% endfor %}
< / select >
2015-07-26 16:25:52 +00:00
< / div >
< / div >
2015-08-09 17:52:24 +00:00
< div class = "form-group backup-target-s3" >
2015-08-09 18:25:26 +00:00
< label for = "backup-target-s3-path" class = "col-sm-2 control-label" > S3 Path< / label >
2015-07-26 16:25:52 +00:00
< div class = "col-sm-8" >
2015-08-09 18:25:26 +00:00
< input type = "text" placeholder = "your-bucket-name/backup-directory" class = "form-control" rows = "1" id = "backup-target-s3-path" >
2015-07-26 16:25:52 +00:00
< / div >
< / div >
2015-08-09 17:52:24 +00:00
< div class = "form-group backup-target-s3" >
2015-08-09 18:25:26 +00:00
< label for = "backup-target-user" class = "col-sm-2 control-label" > S3 Access Key< / label >
2015-07-26 16:25:52 +00:00
< div class = "col-sm-8" >
2015-08-09 18:25:26 +00:00
< input type = "text" class = "form-control" rows = "1" id = "backup-target-user" >
< / div >
< / div >
< div class = "form-group backup-target-s3" >
< label for = "backup-target-pass" class = "col-sm-2 control-label" > S3 Secret Access Key< / label >
< div class = "col-sm-8" >
< input type = "text" class = "form-control" rows = "1" id = "backup-target-pass" >
2015-07-26 16:25:52 +00:00
< / div >
< / div >
< div class = "form-group" >
< div class = "col-sm-offset-2 col-sm-11" >
< button id = "set-s3-backup-button" type = "submit" class = "btn btn-primary" > Save< / button >
< / div >
< / div >
< / form >
2015-08-09 17:52:24 +00:00
< p > Copy the encryption password from < tt id = "backup-encpassword-file" > < / tt > to a safe and secure location. You will need this file to decrypt backup files.< / div > < / p >
< h3 > Available Backups< / h3 >
2014-09-01 13:06:38 +00:00
2015-08-09 17:52:24 +00:00
< p > The backup location currently contains the backups listed below. The total size of the backups is currently < span id = "backup-total-size" > < / span > .< / p >
2014-09-01 13:06:38 +00:00
< table id = "backup-status" class = "table" style = "width: auto" >
< thead >
< th colspan = "2" > When< / th >
< th > Type< / th >
< th > Size< / th >
2014-09-08 20:09:18 +00:00
< th > Deleted in...< / th >
2014-09-01 13:06:38 +00:00
< / thead >
< tbody >
< / tbody >
< / table >
< script >
2015-07-26 16:25:52 +00:00
function toggle_form() {
2015-08-09 18:25:26 +00:00
var target_type = $("#backup-target-type").val();
$(".backup-target-local, .backup-target-s3").hide();
2015-08-09 17:52:24 +00:00
$(".backup-target-" + target_type).show();
2015-07-26 16:25:52 +00:00
}
2014-09-01 13:06:38 +00:00
function nice_size(bytes) {
var powers = ['bytes', 'KB', 'MB', 'GB', 'TB'];
while (true) {
if (powers.length == 1) break;
if (bytes < 1000 ) break ;
bytes /= 1024;
powers.shift();
}
2014-10-07 20:24:11 +00:00
// round to have three significant figures but at most one decimal place
if (bytes >= 100)
bytes = Math.round(bytes)
else
bytes = Math.round(bytes*10)/10;
return bytes + " " + powers[0];
2014-09-01 13:06:38 +00:00
}
function show_system_backup() {
2015-07-26 16:25:52 +00:00
show_custom_backup()
2014-09-01 13:06:38 +00:00
$('#backup-status tbody').html("< tr > < td colspan = '2' class = 'text-muted' > Loading...< / td > < / tr > ")
api(
"/system/backup/status",
"GET",
{ },
function(r) {
$('#backup-status tbody').html("");
var total_disk_size = 0;
2014-10-15 16:31:08 +00:00
if (r.backups.length == 0) {
var tr = $('< tr > < td colspan = "3" > No backups have been made yet.< / td > < / tr > ');
$('#backup-status tbody').append(tr);
}
2014-09-01 13:06:38 +00:00
for (var i = 0; i < r.backups.length ; i + + ) {
var b = r.backups[i];
var tr = $('< tr / > ');
if (b.full) tr.addClass("full-backup");
tr.append( $('< td / > ').text(b.date_str + " " + r.tz) );
tr.append( $('< td / > ').text(b.date_delta + " ago") );
2014-09-08 20:09:18 +00:00
tr.append( $('< td / > ').text(b.full ? "full" : "increment") );
2015-03-26 12:27:26 +00:00
tr.append( $('< td style = "text-align: right" / > ').text( nice_size(b.size)) );
2014-09-08 20:09:18 +00:00
if (b.deleted_in)
tr.append( $('< td / > ').text(b.deleted_in) );
else
2015-03-08 20:55:39 +00:00
tr.append( $('< td class = "text-muted" > unknown< / td > ') );
2014-09-01 13:06:38 +00:00
$('#backup-status tbody').append(tr);
total_disk_size += b.size;
}
$('#backup-total-size').text(nice_size(total_disk_size));
})
}
2015-07-26 16:25:52 +00:00
function show_custom_backup() {
2015-08-09 18:25:26 +00:00
$(".backup-target-local, .backup-target-s3").hide();
2015-07-26 16:25:52 +00:00
api(
2015-07-27 22:34:11 +00:00
"/system/backup/config",
2015-07-26 16:25:52 +00:00
"GET",
{ },
function(r) {
2015-08-09 18:25:26 +00:00
if (r.target == "file://" + r.file_target_directory) {
$("#backup-target-type").val("local");
} else if (r.target.substring(0, 5) == "s3://") {
$("#backup-target-type").val("s3");
var hostpath = r.target.substring(5).split('/');
var host = hostpath.shift();
$("#backup-target-s3-host").val(host);
$("#backup-target-s3-path").val(hostpath.join('/'));
}
$("#backup-target-user").val(r.target_user);
$("#backup-target-pass").val(r.target_pass);
2015-07-27 20:18:19 +00:00
$("#min-age").val(r.min_age_in_days);
2015-08-09 17:52:24 +00:00
$('#backup-location').text(r.file_target_directory);
$('#backup-encpassword-file').text(r.enc_pw_file);
2015-07-26 16:25:52 +00:00
toggle_form()
})
}
function set_custom_backup() {
2015-08-09 18:25:26 +00:00
var target_type = $("#backup-target-type").val();
var target_user = $("#backup-target-user").val();
var target_pass = $("#backup-target-pass").val();
var target;
if (target_type == "local")
target = target_type;
else if (target_type == "s3")
target = "s3://" + $("#backup-target-s3-host").val() + "/" + $("#backup-target-s3-path").val();
2015-07-27 20:18:19 +00:00
var min_age = $("#min-age").val();
2015-07-26 16:25:52 +00:00
api(
2015-07-27 22:34:11 +00:00
"/system/backup/config",
2015-07-26 16:25:52 +00:00
"POST",
{
target: target,
target_user: target_user,
target_pass: target_pass,
2015-07-27 20:18:19 +00:00
min_age: min_age
2015-07-26 16:25:52 +00:00
},
function(r) {
// Responses are multiple lines of pre-formatted text.
show_modal_error("Backup configuration", $("< pre / > ").text(r));
},
function(r) {
show_modal_error("Backup configuration (error)", r);
});
return false;
}
2014-09-01 13:06:38 +00:00
< / script >