Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Feb 28, 2024
1 parent f62ff99 commit 9e2655f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/scripts/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@
}

$abSettings = new ABSettings();
$abDestination = rtrim($abSettings->destination, '/') . '/ab_' . date("Ymd_His");

ABHelper::handlePrePostScript($abSettings->preRunScript, 'pre-run', $abDestination);

if (empty($abSettings->destination)) {
ABHelper::backupLog("Destination is not set!", ABHelper::LOGLEVEL_ERR);
goto end;
}

$abDestination = rtrim($abSettings->destination, '/') . '/ab_' . date("Ymd_His");

ABHelper::handlePrePostScript($abSettings->preRunScript, 'pre-run', $abDestination);

if (!file_exists($abSettings->destination) || !is_writable($abSettings->destination)) {
ABHelper::backupLog("Destination is unavailable or not writeable!", ABHelper::LOGLEVEL_ERR);
goto end;
Expand Down Expand Up @@ -371,6 +372,8 @@
ABHelper::notify("Appdata Backup", "Backup done [$backupDuration]!", "The backup was successful and took $backupDuration!");
}

ABHelper::handlePrePostScript($abSettings->postRunScript, 'post-run', $abDestination, (ABHelper::$errorOccured ? 'false' : 'true'));

if (!empty($abDestination)) {
copy(ABSettings::$tempFolder . '/' . ABSettings::$logfile, $abDestination . '/backup.log');
copy(ABSettings::getConfigPath(), $abDestination . '/' . ABSettings::$settingsFile);
Expand All @@ -392,6 +395,4 @@
}
unlink(ABSettings::$tempFolder . '/' . ABSettings::$stateFileScriptRunning);

ABHelper::handlePrePostScript($abSettings->postRunScript, 'post-run', $abDestination, (ABHelper::$errorOccured ? 'false' : 'true'));

exit(ABHelper::$errorOccured ? 1 : 0);

0 comments on commit 9e2655f

Please sign in to comment.