upload-backup: add configurable random delay

This commit is contained in:
Christian Hesse 2021-02-23 09:56:28 +01:00
parent 8b44964a36
commit bc8b19fc31
2 changed files with 10 additions and 2 deletions

View file

@ -24,6 +24,7 @@ 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
* `BackupUploadUrl`: url to upload to * `BackupUploadUrl`: url to upload to
* `BackupUploadUser`: username for server authentication * `BackupUploadUser`: username for server authentication
* `BackupUploadPass`: password for server authentication * `BackupUploadPass`: password for server authentication

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 BackupUploadPass; :global BackupUploadPass;
@ -23,18 +24,24 @@
:global DeviceInfo; :global DeviceInfo;
:global IfThenElse; :global IfThenElse;
:global LogPrintExit2; :global LogPrintExit2;
:global RandomDelay;
:global ScriptFromTerminal;
:global SendNotification; :global SendNotification;
:global SymbolForNotification; :global SymbolForNotification;
: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;
} }
$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";