Skip to content

Commit

Permalink
Prepare for error handling during backup/restore
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Apr 2, 2023
1 parent ae78b7e commit b55aa39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/include/ABHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public static function backupContainer($container, $destination) {
return $containerSettings['ignoreBackupErrors'] == 'yes';
}
} else {
ABHelper::backupLog("Skipping verification for this container because its not wanted!", ABHelper::LOGLEVEL_WARN);
self::backupLog("Skipping verification for this container because its not wanted!", self::LOGLEVEL_WARN);
}
return true;
}
Expand Down Expand Up @@ -430,10 +430,17 @@ public static function isVolumeWithinAppdata($volume) {
foreach ($abSettings->allowedSources as $appdataPath) {
$appdataPath = rtrim($appdataPath, '/');
if (str_starts_with($volume, $appdataPath)) {
ABHelper::backupLog(__METHOD__ . ": $appdataPath IS within $volume.", ABHelper::LOGLEVEL_DEBUG);
self::backupLog(__METHOD__ . ": $appdataPath IS within $volume.", self::LOGLEVEL_DEBUG);
return true;
}
}
return false;
}

public static function errorHandler(int $errno, string $errstr, string $errfile, int $errline): bool {
self::notify("Appdata Backup PHP error", "Appdata Backup PHP error", "got PHP error: $errno / $errstr $errfile:$errline", 'alert');
self::backupLog("got PHP error: $errno / $errstr $errfile:$errline", self::LOGLEVEL_ERR);

return true;
}
}
2 changes: 2 additions & 0 deletions src/scripts/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
require_once("/usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php");
require_once dirname(__DIR__) . '/include/ABHelper.php';

//set_error_handler("unraid\plugins\AppdataBackup\ABHelper::errorHandler");

/**
* Helper for later renaming of the backup folder to suffix -failed
*/
Expand Down
2 changes: 2 additions & 0 deletions src/scripts/restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

require_once __DIR__ . '/../include/ABHelper.php';

//set_error_handler("unraid\plugins\AppdataBackup\ABHelper::errorHandler");

if (ABHelper::scriptRunning()) {
ABHelper::notify("Still running", "There is something running already.");
exit;
Expand Down

0 comments on commit b55aa39

Please sign in to comment.