aboutsummaryrefslogtreecommitdiffstats
path: root/email-backup
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-12-12 21:54:29 +0100
committerGravatar Christian Hesse <mail@eworm.de>2018-12-12 21:54:29 +0100
commitdee4495c0c3f80e8e58c219fc541f1c738009d5d (patch)
tree004643cefd032d476b58982a522657e8c0aafb3e /email-backup
parent587fef54517c2fdc4e03079be2d5ce12b6d0a59e (diff)
email-backup: send backup and config export in one mail
Diffstat (limited to 'email-backup')
-rw-r--r--email-backup43
1 files changed, 23 insertions, 20 deletions
diff --git a/email-backup b/email-backup
index 7221984..be1f35f 100644
--- a/email-backup
+++ b/email-backup
@@ -12,8 +12,13 @@
:global "backup-send-export";
:global "backup-password";
+:if ($"backup-send-binary" = false && $"backup-send-export" = false) do={
+ :error ("Configured to send neither backup nor config export.");
+}
+
# filename based on identity
:local filename ($identity . "." . $domain);
+:local attach [ :toarray "" ];
# get some system information
:local model [ / system routerboard get model ];
@@ -21,32 +26,30 @@
:local channel [ / system package update get channel ];
:local installedversion [ / system package update get installed-version ];
-# create and email binary backup
+# create binary backup
:if ($"backup-send-binary" = true) do={
/ system backup save name=$filename password=$"backup-password";
/ delay delay-time=10;
- / tool e-mail send to=$"email-backup-to" cc=$"email-backup-cc" \
- subject=("[" . $identity . "] Backup") \
- body=("Backup file for " . $identity . " is attached.\n\n" . \
- "Routerboard: " . $model . "\n" . \
- "Serial number: " . $serialnumber . "\n" . \
- "Hostname: " . $identity . "\n" . \
- "Channel: " . $channel . "\n" . \
- "RouterOS: " . $installedversion) \
- file=($filename . ".backup");
+ :set attach ( $attach, ($filename . ".backup") );
}
-# create and email configuration export
+# create configuration export
:if ($"backup-send-export" = true) do={
/ export terse file=$filename;
/ delay delay-time=10;
- / tool e-mail send to=$"email-backup-to" cc=$"email-backup-cc" \
- subject=("[" . $identity . "] Config") \
- body=("Config file for " . $identity . " is attached.\n\n" . \
- "Routerboard: " . $model . "\n" . \
- "Serial number: " . $serialnumber . "\n" . \
- "Hostname: " . $identity . "\n" . \
- "Channel: " . $channel . "\n" . \
- "RouterOS: " . $installedversion) \
- file=($filename . ".rsc");
+ :set attach ( $attach, ($filename . ".rsc") );
+}
+
+# email files
+/ tool e-mail send to=$"email-backup-to" cc=$"email-backup-cc" \
+ subject=("[" . $identity . "] Backup & Config") \
+ body=("Backup and config export for " . $identity . ".\n\n" . \
+ "Routerboard: " . $model . "\n" . \
+ "Serial number: " . $serialnumber . "\n" . \
+ "Hostname: " . $identity . "\n" . \
+ "Channel: " . $channel . "\n" . \
+ "RouterOS: " . $installedversion . "\n\n" . \
+ "Backup attached: " . $"backup-send-binary" . "\n" . \
+ "Config attached: " . $"backup-send-export") \
+ file=$attach;
}