aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-02-23 09:56:28 +0100
committerGravatar Christian Hesse <mail@eworm.de>2021-02-24 21:51:56 +0100
commitbc8b19fc31a2c2c437c6fea703b601b802470e02 (patch)
tree1b9a729c12936ec9452c4e4e1889f3105225a86d
parent8b44964a36e5a5eebe70ab94eae6086bfbdbfb36 (diff)
upload-backup: add configurable random delay
-rw-r--r--doc/upload-backup.md1
-rw-r--r--upload-backup11
2 files changed, 10 insertions, 2 deletions
diff --git a/doc/upload-backup.md b/doc/upload-backup.md
index bbfbcc4..e6ba9e2 100644
--- a/doc/upload-backup.md
+++ b/doc/upload-backup.md
@@ -24,6 +24,7 @@ The configuration goes to `global-config-overlay`, these are the parameters:
* `BackupSendBinary`: whether to send binary backup
* `BackupSendExport`: whether to send configuration export
* `BackupPassword`: password to encrypt the backup with
+* `BackupRandomDelay`: delay up to amount of seconds when run from scheduler
* `BackupUploadUrl`: url to upload to
* `BackupUploadUser`: username for server authentication
* `BackupUploadPass`: password for server authentication
diff --git a/upload-backup b/upload-backup
index 1e3e8e8..15adc1f 100644
--- a/upload-backup
+++ b/upload-backup
@@ -11,6 +11,7 @@
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BackupPassword;
+:global BackupRandomDelay;
:global BackupSendBinary;
:global BackupSendExport;
:global BackupUploadPass;
@@ -23,18 +24,24 @@
:global DeviceInfo;
:global IfThenElse;
:global LogPrintExit2;
+:global RandomDelay;
+:global ScriptFromTerminal;
:global SendNotification;
:global SymbolForNotification;
:global WaitForFile;
:global WaitFullyConnected;
-$WaitFullyConnected;
-
:if ($BackupSendBinary != true && \
$BackupSendExport != true) do={
$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
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
:local BackupFile "none";