Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions backup-module/backup_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ function backup_controller()
}
}

if ($route->action == 'exportlink') {
$route->format = "text";
$backup_filename="emoncms-backup-".gethostname()."-".date("Y-m-d").".tar.gz";
if (file_exists($parsed_ini['backup_location']."/".$backup_filename) && !file_exists("/tmp/backuplock")) {
$result = '<br><br><b>Right Click > Download:</b><br><a href="'.$path.'backup/download">'.$backup_filename.'</a>';
} else {
$result = '<br><br>No backup file exists for today<b></b>';
}
}

if ($route->action == 'importlog') {
$route->format = "text";
if (file_exists($import_logfile)) {
Expand Down
18 changes: 11 additions & 7 deletions backup-module/backup_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,8 @@
<button id="emonpi-backup" class="btn btn-info"><?php echo _('Create backup'); ?></button>
<br><br>
<pre id="export-log-bound" class="log"><div id="export-log"></div></pre>
<?php
$backup_filename="emoncms-backup-".gethostname()."-".date("Y-m-d").".tar.gz";
if (file_exists($parsed_ini['backup_location']."/".$backup_filename) && !file_exists("/tmp/backuplock")) {
echo '<br><br><b>Right Click > Download:</b><br><a href="'.$path.'backup/download">'.$backup_filename.'</a>';
}
?>
<div id="export-link"></div>
<br><br>
<p>Once export is complete refresh page to see download link.</p>
<p><i>Note: Export can take a long time; please be patient.</i></p>
</div>
</div>
Expand Down Expand Up @@ -136,6 +130,7 @@ function selectTab(hash) {
export_updater = setInterval(export_log_update,1000);
import_updater = setInterval(import_log_update,1000);
usb_import_updater = setInterval(usb_import_log_update,1000);
export_log_link();

$("#emonpi-backup").click(function() {
$.ajax({ url: path+"backup/start", async: true, dataType: "text", success: function(result) {
Expand Down Expand Up @@ -163,11 +158,20 @@ function export_log_update() {

if (result.indexOf("=== Emoncms export complete! ===")!=-1 || result.indexOf("=== Emoncms export completed with ERRORS! ===")!=-1) {
clearInterval(export_updater);
export_log_link();
}
}
});
}

function export_log_link() {
$.ajax({ url: path+"backup/exportlink", async: true, dataType: "text", success: function(result)
{
$("#export-link").html(result);
}
});
}

function import_log_update() {
$.ajax({ url: path+"backup/importlog", async: true, dataType: "text", success: function(result)
{
Expand Down