backup-email: early exit with :exit

This commit is contained in:
Christian Hesse 2026-01-19 14:59:06 +01:00
parent d4547ecbfa
commit 3ad7b5f2bb

View file

@ -9,7 +9,6 @@
# create and email backup and config file # create and email backup and config file
# https://rsc.eworm.de/doc/backup-email.md # https://rsc.eworm.de/doc/backup-email.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -41,28 +40,24 @@
:if ([ :typeof $SendEMail2 ] = "nothing") do={ :if ([ :typeof $SendEMail2 ] = "nothing") do={
$LogPrint error $ScriptName ("The module for sending notifications via e-mail is not installed."); $LogPrint error $ScriptName ("The module for sending notifications via e-mail is not installed.");
:set ExitOK true; :exit;
:error false;
} }
:if ($BackupSendBinary != true && \ :if ($BackupSendBinary != true && \
$BackupSendExport != true) do={ $BackupSendExport != true) do={
$LogPrint error $ScriptName ("Configured to send neither backup nor config export."); $LogPrint error $ScriptName ("Configured to send neither backup nor config export.");
:set ExitOK true; :exit;
:error false;
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={
$LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); $LogPrint warning $ScriptName ("Running from backup partition, refusing to act.");
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -82,8 +77,7 @@
:if ([ $MkDir $DirName ] = false) do={ :if ([ $MkDir $DirName ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!"); $LogPrint error $ScriptName ("Failed creating directory!");
:set ExitOK true; :exit;
:error false;
} }
# binary backup # binary backup
@ -139,5 +133,5 @@
} }
# do not remove the files here, as the mail is still queued! # do not remove the files here, as the mail is still queued!
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError false [ :jobname ] $Err;
} }