email-backup: add configurable random delay

This commit is contained in:
Christian Hesse 2021-02-23 09:56:12 +01:00
parent 6770a15a7d
commit 8b44964a36
2 changed files with 11 additions and 3 deletions

View File

@ -20,11 +20,12 @@ Just install the script:
Configuration Configuration
------------- -------------
The configuration goes to `global-config-overlay`, These are the parameters: The configuration goes to `global-config-overlay`, these are the parameters:
* `BackupSendBinary`: whether to send binary backup * `BackupSendBinary`: whether to send binary backup
* `BackupSendExport`: whether to send configuration export * `BackupSendExport`: whether to send configuration export
* `BackupPassword`: password to encrypt the backup with * `BackupPassword`: password to encrypt the backup with
* `BackupRandomDelay`: delay up to amount of seconds when run from scheduler
* `EmailBackupTo`: e-mail address to send to * `EmailBackupTo`: e-mail address to send to
* `EmailBackupCc`: e-mail address(es) to send in copy * `EmailBackupCc`: e-mail address(es) to send in copy

View File

@ -11,6 +11,7 @@
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BackupPassword; :global BackupPassword;
:global BackupRandomDelay;
:global BackupSendBinary; :global BackupSendBinary;
:global BackupSendExport; :global BackupSendExport;
:global Domain; :global Domain;
@ -21,11 +22,11 @@
:global CharacterReplace; :global CharacterReplace;
:global DeviceInfo; :global DeviceInfo;
:global LogPrintExit2; :global LogPrintExit2;
:global RandomDelay;
:global ScriptFromTerminal;
:global WaitForFile; :global WaitForFile;
:global WaitFullyConnected; :global WaitFullyConnected;
$WaitFullyConnected;
:if ($BackupSendBinary != true && \ :if ($BackupSendBinary != true && \
$BackupSendExport != true) do={ $BackupSendExport != true) do={
$LogPrintExit2 error $0 ("Configured to send neither backup nor config export.") true; $LogPrintExit2 error $0 ("Configured to send neither backup nor config export.") true;
@ -35,6 +36,12 @@ $WaitFullyConnected;
$LogPrintExit2 error $0 ("Configuration is missing recipient for e-mail backup.") true; $LogPrintExit2 error $0 ("Configuration is missing recipient for e-mail backup.") true;
} }
$WaitFullyConnected;
:if ([ $ScriptFromTerminal $0 ] = false && $BackupRandomDelay > 0) do={
$RandomDelay $BackupRandomDelay;
}
# filename based on identity # filename based on identity
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ]; :local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
:local BackupFile "none"; :local BackupFile "none";