aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-02-23 09:56:12 +0100
committerGravatar Christian Hesse <mail@eworm.de>2021-02-24 21:51:56 +0100
commit8b44964a36e5a5eebe70ab94eae6086bfbdbfb36 (patch)
tree5b4688ddbf3ed7aadb68fd0c51f87a595ff66b53
parent6770a15a7d1df1ef5f2cc0a6f82e0d4f82b214d6 (diff)
email-backup: add configurable random delay
-rw-r--r--doc/email-backup.md3
-rw-r--r--email-backup11
2 files changed, 11 insertions, 3 deletions
diff --git a/doc/email-backup.md b/doc/email-backup.md
index 7f89a06..4b769ec 100644
--- a/doc/email-backup.md
+++ b/doc/email-backup.md
@@ -20,11 +20,12 @@ Just install the script:
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
* `BackupSendExport`: whether to send configuration export
* `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
* `EmailBackupCc`: e-mail address(es) to send in copy
diff --git a/email-backup b/email-backup
index 129075a..b9e91c2 100644
--- a/email-backup
+++ b/email-backup
@@ -11,6 +11,7 @@
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BackupPassword;
+:global BackupRandomDelay;
:global BackupSendBinary;
:global BackupSendExport;
:global Domain;
@@ -21,11 +22,11 @@
:global CharacterReplace;
:global DeviceInfo;
:global LogPrintExit2;
+:global RandomDelay;
+:global ScriptFromTerminal;
:global WaitForFile;
:global WaitFullyConnected;
-$WaitFullyConnected;
-
:if ($BackupSendBinary != true && \
$BackupSendExport != true) do={
$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;
}
+$WaitFullyConnected;
+
+:if ([ $ScriptFromTerminal $0 ] = false && $BackupRandomDelay > 0) do={
+ $RandomDelay $BackupRandomDelay;
+}
+
# filename based on identity
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
:local BackupFile "none";