Skip to content

Commit

Permalink
2023.03.27b1
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Mar 27, 2023
1 parent 6b38be9 commit 8fb3c39
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion appdata.backup.beta.plg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!ENTITY name "appdata.backup.beta">
<!ENTITY author "Robin Kluth">
<!ENTITY version "2023.03.27b1">
<!ENTITY sha256 "e0ed774bba1360147c47c028a58d96e6ca7f13690caeabb78ddd93249ff7996e">
<!ENTITY sha256 "5bd76d929c12bfc1cd0d8377600fede227507a653a883879207fbe784cad12ea">
<!ENTITY launch "Settings/AB.Beta.Main">
<!ENTITY plugdir "/usr/local/emhttp/plugins/&name;">
<!ENTITY github "Commifreak/unraid-appdata.backup">
Expand Down
2 changes: 1 addition & 1 deletion src/include/ABSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function getConfigPath() {
*/
public function getContainerSpecificSettings($name, $setEmptyToDefault = true) {
if (!isset($this->containerSettings[$name])) {
return array_merge($this->defaults, ['skip' => 'no', 'exclude' => [], 'dontStop' => 'no']);
return array_merge($this->defaults, ['skip' => 'no', 'exclude' => '', 'dontStop' => 'no']);
}

$settings = $this->containerSettings[$name];
Expand Down
27 changes: 26 additions & 1 deletion src/include/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
use unraid\plugins\AppdataBackup\ABSettings;

if (isset($_GET['action'])) {
header('Content-Type: application/json; charset=utf-8');

if ($_GET['action'] != 'dlLog') {
header('Content-Type: application/json; charset=utf-8');
}

switch ($_GET['action']) {
case 'getBackupState':

Expand Down Expand Up @@ -98,6 +102,27 @@
case 'startRestore':
exec('php ' . dirname(__DIR__) . '/scripts/restore.php ' . escapeshellarg(json_encode($_GET)) . ' > /dev/null &');
break;
case 'dlLog':
$filename = ($_GET['type'] ?? 'dlLogBtn') == 'dlLogBtn' ? ABSettings::$logfile : ABSettings::$debugLogFile;
$filePath = ABSettings::$tempFolder . '/' . $filename;

header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');

if (!file_exists($filePath)) {
echo "Log does not exist!";
exit;
}

header('Content-Length: ' . filesize($filePath));
readfile($filePath);
exit;


break;


}
Expand Down
8 changes: 8 additions & 0 deletions src/pages/content/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
<h3>The backup is <span id="backupStatusText" class=""></span>.</h3>
<div style='border: 1px solid red; height:500px; overflow:auto' id='abLog'>Loading...</div>
<input type='button' id="abortBtn" value='Abort' disabled/>
<input type='button' id="dlLogBtn" value='Download log' disabled/>
<input type='button' id="dlDbgLogBtn" value='Download debug log' disabled/>


<script>
Expand All @@ -60,6 +62,10 @@
});
});
});

$('#dlLogBtn, #dlDbgLogBtn').on('click', function () {
window.location = url + '?action=dlLog&type=' + $(this).attr('id');
});
});

function checkBackup() {
Expand All @@ -69,13 +75,15 @@ function checkBackup() {
}).done(function (data) {
if (data.running) {
$('#abortBtn').removeAttr('disabled');
$('#dlLogBtn, #dlDbgLogBtn').attr('disabled', 'disabled');
$('#backupStatusText').removeClass('backupNotRunning');
$('#backupStatusText').addClass('backupRunning');
$('#abLog').animate({
scrollTop: $('#abLog')[0].scrollHeight - $('#abLog')[0].clientHeight
}, 100);
} else {
$('#abortBtn').attr('disabled', 'disabled');
$('#dlLogBtn, #dlDbgLogBtn').removeAttr('disabled');
$('#backupStatusText').removeClass('backupRunning');
$('#backupStatusText').addClass('backupNotRunning');
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/content/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class="fa fa-info"></i> Those must return exit code 0 for success detection</sma
<p>If you need assistance, you can ask in the unraid community for help.</p>
<dl>
<dt>Plugin thread @ Unraid community</dt>
<dd><a href="https://forums.unraid.net/topic/132721-plugin-ca-appdata-backup-restore-v3" target="_blank">Open</a>
<dd><a href="<?= ABSettings::$supportUrl ?>" target="_blank">Open</a>
</dd>

<dt>Maintainer</dt>
Expand Down

0 comments on commit 8fb3c39

Please sign in to comment.