email-backup: use $SendEMail2

This drops $EmailBackupTo & $EmailBackupCc from settings! Use settings
overwrite if required:

:global EmailGeneralToOverride {
  "email-backup"="backup@example.com";
}
This commit is contained in:
Christian Hesse 2021-04-29 16:26:31 +02:00
parent 529cefffaf
commit d2560db5c9
6 changed files with 15 additions and 23 deletions

View file

@ -26,10 +26,8 @@ The configuration goes to `global-config-overlay`, these are the parameters:
* `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
Also valid e-mail settings in `/ tool e-mail` are required to send mails.
Also valid e-mail settings are required to send mails.
Usage and invocation
--------------------

View file

@ -15,8 +15,6 @@
:global BackupSendBinary;
:global BackupSendExport;
:global Domain;
:global EmailBackupCc;
:global EmailBackupTo;
:global Identity;
:global CharacterReplace;
@ -25,6 +23,7 @@
:global MkDir;
:global RandomDelay;
:global ScriptFromTerminal;
:global SendEMail2;
:global WaitForFile;
:global WaitFullyConnected;
@ -33,10 +32,6 @@
$LogPrintExit2 error $0 ("Configured to send neither backup nor config export.") true;
}
:if ([ :len $EmailBackupTo ] = 0) do={
$LogPrintExit2 error $0 ("Configuration is missing recipient for e-mail backup.") true;
}
$WaitFullyConnected;
:if ([ $ScriptFromTerminal $0 ] = false && $BackupRandomDelay > 0) do={
@ -71,11 +66,11 @@ $WaitFullyConnected;
}
# send email with status and files
/ tool e-mail send to=$EmailBackupTo cc=$EmailBackupCc \
subject=("[" . $Identity . "] Backup & Config") \
body=("See attached files for backup and config export for " . \
$Identity . ".\n\n" . \
[ $DeviceInfo ] . "\n\n" . \
"Backup file: " . $BackupFile . "\n" . \
"Config file: " . $ConfigFile) \
file=$Attach;
$SendEMail2 ({ origin=$0; \
subject=("Backup & Config"); \
message=("See attached files for backup and config export for " . \
$Identity . ".\n\n" . \
[ $DeviceInfo ] . "\n\n" . \
"Backup file: " . $BackupFile . "\n" . \
"Config file: " . $ConfigFile); \
attach=$Attach });

View file

@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
:global GlobalConfigVersion 48;
:global GlobalConfigVersion 49;
# This is used for DNS and backup file.
:global Domain "example.com";
@ -38,6 +38,7 @@
# TelegramTokenIdOverride and TelegramChatIdOverride like this:
#:global EmailGeneralToOverride {
# "check-certificates"="override@example.com";
# "email-backup"="backup@example.com";
#}
# Toggle this to disable symbols in notifications.
@ -50,9 +51,6 @@
:global BackupSendExport true;
:global BackupPassword "v3ry-s3cr3t";
:global BackupRandomDelay 0;
# These addresses are used to send backup and config export files to.
:global EmailBackupTo "";
:global EmailBackupCc "";
# These credentials are used to upload backup and config export files.
# SFTP authentication is tricky, you may have to limit authentication
# methods for your SSH server.

View file

@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
# Comment or remove to disable news and change notifications.
:global GlobalConfigVersion 48;
:global GlobalConfigVersion 49;
# Copy configuration from global-config here and modify it.

View file

@ -52,6 +52,7 @@
46="Added configurable random delay in backup scripts to stretch execution and prevent resource congestion.";
47="Removed obsolete intermediate certificate 'Let's Encrypt Authority X3' from store.";
48="Added support for overriding e-mail and Telegram settings for every script.";
49="Dropped '\$EmailBackupTo' & '\$EmailBackupCc' from configuration, use settings override if required.";
};
# Migration steps to be applied on script updates

View file

@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version
:global ExpectedConfigVersion 48;
:global ExpectedConfigVersion 49;
# global variables not to be changed by user
:global GlobalFunctionsReady false;