aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-01-05 22:37:35 +0100
committerGravatar Christian Hesse <mail@eworm.de>2022-01-06 08:19:58 +0100
commit95b17ab9a17b7ad11df7c467813a061aead1c835 (patch)
tree5d29fd04bc66168a435af77dd394937841a3d98c
parent8c39f41ffcf3af7fe6d8b4091db5791756f59879 (diff)
rename script email-backup -> backup-email
-rw-r--r--README.md2
-rw-r--r--backup-email80
-rw-r--r--doc/backup-cloud.md2
-rw-r--r--doc/backup-email.md54
-rw-r--r--doc/email-backup.md55
-rw-r--r--doc/packages-update.md4
-rw-r--r--doc/upload-backup.md2
-rw-r--r--email-backup80
-rw-r--r--global-config2
9 files changed, 142 insertions, 139 deletions
diff --git a/README.md b/README.md
index f14403d..1aca7ef 100644
--- a/README.md
+++ b/README.md
@@ -186,6 +186,7 @@ Available scripts
* [Find and remove access list duplicates](doc/accesslist-duplicates.md)
* [Upload backup to Mikrotik cloud](doc/backup-cloud.md)
+* [Send backup via e-mail](doc/backup-email.md)
* [Download packages for CAP upgrade from CAPsMAN](doc/capsman-download-packages.md)
* [Run rolling CAP upgrades from CAPsMAN](doc/capsman-rolling-upgrade.md)
* [Renew locally issued certificates](doc/certificate-renew-issued.md)
@@ -197,7 +198,6 @@ Available scripts
* [Use wireless network with daily psk](doc/daily-psk.md)
* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md)
* [Create DNS records for DHCP leases](doc/dhcp-to-dns.md)
-* [Send backup via e-mail](doc/email-backup.md)
* [Wait for global functions und modules](doc/global-wait.md)
* [Send GPS position to server](doc/gps-track.md)
* [Use WPA2 network with hotspot credentials](doc/hotspot-to-wpa.md)
diff --git a/backup-email b/backup-email
new file mode 100644
index 0000000..bda9215
--- /dev/null
+++ b/backup-email
@@ -0,0 +1,80 @@
+#!rsc by RouterOS
+# RouterOS script: backup-email
+# Copyright (c) 2013-2022 Christian Hesse <mail@eworm.de>
+# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+#
+# provides: backup-script
+#
+# create and email backup and config file
+# https://git.eworm.de/cgit/routeros-scripts/about/doc/backup-email.md
+
+:local 0 "backup-email";
+:global GlobalFunctionsReady;
+:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+
+:global BackupPassword;
+:global BackupRandomDelay;
+:global BackupSendBinary;
+:global BackupSendExport;
+:global Domain;
+:global Identity;
+
+:global CharacterReplace;
+:global DeviceInfo;
+:global LogPrintExit2;
+:global MkDir;
+:global RandomDelay;
+:global ScriptFromTerminal;
+:global SendEMail2;
+:global SymbolForNotification;
+:global WaitForFile;
+:global 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;
+}
+
+:if ([ $MkDir $0 ] = false) do={
+ $LogPrintExit2 error $0 ("Failed creating directory!") true;
+}
+
+# filename based on identity
+:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
+:local FilePath ($0 . "/" . $FileName);
+:local BackupFile "none";
+:local ConfigFile "none";
+:local Attach [ :toarray "" ];
+
+# binary backup
+:if ($BackupSendBinary = true) do={
+ / system backup save encryption=aes-sha256 name=$FilePath password=$BackupPassword;
+ $WaitForFile ($FilePath . ".backup");
+ :set BackupFile ($FileName . ".backup");
+ :set Attach ($Attach, ($FilePath . ".backup"));
+}
+
+# create configuration export
+:if ($BackupSendExport = true) do={
+ / export terse file=$FilePath;
+ $WaitForFile ($FilePath . ".rsc");
+ :set ConfigFile ($FileName . ".rsc");
+ :set Attach ($Attach, ($FilePath . ".rsc"));
+}
+
+# send email with status and files
+$SendEMail2 ({ origin=$0; \
+ subject=([ $SymbolForNotification "floppy-disk,incoming-envelope" ] . \
+ "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; remove-attach=true });
diff --git a/doc/backup-cloud.md b/doc/backup-cloud.md
index 18b9ec1..a31a736 100644
--- a/doc/backup-cloud.md
+++ b/doc/backup-cloud.md
@@ -46,7 +46,7 @@ Creating a scheduler may be an option:
See also
--------
-* [Send backup via e-mail](email-backup.md)
+* [Send backup via e-mail](backup-email.md)
* [Upload backup to server](upload-backup.md)
---
diff --git a/doc/backup-email.md b/doc/backup-email.md
new file mode 100644
index 0000000..7361b44
--- /dev/null
+++ b/doc/backup-email.md
@@ -0,0 +1,54 @@
+Send backup via e-mail
+======================
+
+[◀ Go back to main README](../README.md)
+
+🛈 This script can not be used on its own but requires the base installation.
+See [main README](../README.md) for details.
+
+Description
+-----------
+
+This script sends binary backup (`/ system backup save`) and complete
+configuration export (`/ export terse`) via e-mail.
+
+
+Requirements and installation
+-----------------------------
+
+Just install the script:
+
+ $ScriptInstallUpdate backup-email;
+
+Configuration
+-------------
+
+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
+
+Also valid e-mail settings are required to send mails.
+
+Usage and invocation
+--------------------
+
+Just run the script:
+
+ / system script run backup-email;
+
+Creating a scheduler may be an option:
+
+ / system scheduler add interval=1w name=backup-email on-event="/ system script run backup-email;" start-time=09:15:00;
+
+See also
+--------
+
+* [Upload backup to Mikrotik cloud](backup-cloud.md)
+* [Upload backup to server](upload-backup.md)
+
+---
+[◀ Go back to main README](../README.md)
+[▲ Go back to top](#top)
diff --git a/doc/email-backup.md b/doc/email-backup.md
index bb48e9d..d674743 100644
--- a/doc/email-backup.md
+++ b/doc/email-backup.md
@@ -1,54 +1 @@
-Send backup via e-mail
-======================
-
-[◀ Go back to main README](../README.md)
-
-🛈 This script can not be used on its own but requires the base installation.
-See [main README](../README.md) for details.
-
-Description
------------
-
-This script sends binary backup (`/ system backup save`) and complete
-configuration export (`/ export terse`) via e-mail.
-
-
-Requirements and installation
------------------------------
-
-Just install the script:
-
- $ScriptInstallUpdate email-backup;
-
-Configuration
--------------
-
-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
-
-Also valid e-mail settings are required to send mails.
-
-Usage and invocation
---------------------
-
-Just run the script:
-
- / system script run email-backup;
-
-Creating a scheduler may be an option:
-
- / system scheduler add interval=1w name=email-backup on-event="/ system script run email-backup;" start-time=09:15:00;
-
-See also
---------
-
-* [Upload backup to Mikrotik cloud](backup-cloud.md)
-* [Upload backup to server](upload-backup.md)
-
----
-[◀ Go back to main README](../README.md)
-[▲ Go back to top](#top)
+This script has been renamed. Please see [backup-email](backup-email.md). \ No newline at end of file
diff --git a/doc/packages-update.md b/doc/packages-update.md
index cc4a29b..8502a36 100644
--- a/doc/packages-update.md
+++ b/doc/packages-update.md
@@ -16,7 +16,7 @@ verification.
But it provides some extra functionality:
-* send backup via e-mail if [email-backup](email-backup.md) is installed
+* send backup via e-mail if [backup-email](backup-email.md) is installed
* upload backup if [upload-backup](upload-backup.md) is installed
* schedule reboot at night
@@ -41,7 +41,7 @@ See also
--------
* [Notify on RouterOS update](check-routeros-update.md)
-* [Send backup via e-mail](email-backup.md)
+* [Send backup via e-mail](backup-email.md)
* [Upload backup to server](upload-backup.md)
---
diff --git a/doc/upload-backup.md b/doc/upload-backup.md
index 203f7f6..33022f4 100644
--- a/doc/upload-backup.md
+++ b/doc/upload-backup.md
@@ -62,7 +62,7 @@ Creating a scheduler may be an option:
See also
--------
-* [Send backup via e-mail](email-backup.md)
+* [Send backup via e-mail](backup-email.md)
* [Upload backup to Mikrotik cloud](backup-cloud.md)
---
diff --git a/email-backup b/email-backup
index 1d4099c..2c48f07 100644
--- a/email-backup
+++ b/email-backup
@@ -1,80 +1,2 @@
#!rsc by RouterOS
-# RouterOS script: email-backup
-# Copyright (c) 2013-2022 Christian Hesse <mail@eworm.de>
-# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
-#
-# provides: backup-script
-#
-# create and email backup and config file
-# https://git.eworm.de/cgit/routeros-scripts/about/doc/email-backup.md
-
-:local 0 "email-backup";
-:global GlobalFunctionsReady;
-:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-
-:global BackupPassword;
-:global BackupRandomDelay;
-:global BackupSendBinary;
-:global BackupSendExport;
-:global Domain;
-:global Identity;
-
-:global CharacterReplace;
-:global DeviceInfo;
-:global LogPrintExit2;
-:global MkDir;
-:global RandomDelay;
-:global ScriptFromTerminal;
-:global SendEMail2;
-:global SymbolForNotification;
-:global WaitForFile;
-:global 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;
-}
-
-:if ([ $MkDir $0 ] = false) do={
- $LogPrintExit2 error $0 ("Failed creating directory!") true;
-}
-
-# filename based on identity
-:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
-:local FilePath ($0 . "/" . $FileName);
-:local BackupFile "none";
-:local ConfigFile "none";
-:local Attach [ :toarray "" ];
-
-# binary backup
-:if ($BackupSendBinary = true) do={
- / system backup save encryption=aes-sha256 name=$FilePath password=$BackupPassword;
- $WaitForFile ($FilePath . ".backup");
- :set BackupFile ($FileName . ".backup");
- :set Attach ($Attach, ($FilePath . ".backup"));
-}
-
-# create configuration export
-:if ($BackupSendExport = true) do={
- / export terse file=$FilePath;
- $WaitForFile ($FilePath . ".rsc");
- :set ConfigFile ($FileName . ".rsc");
- :set Attach ($Attach, ($FilePath . ".rsc"));
-}
-
-# send email with status and files
-$SendEMail2 ({ origin=$0; \
- subject=([ $SymbolForNotification "floppy-disk,incoming-envelope" ] . \
- "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; remove-attach=true });
+# dummy for migration
diff --git a/global-config b/global-config
index cd8ba58..1250818 100644
--- a/global-config
+++ b/global-config
@@ -49,7 +49,7 @@
# variable name, like this:
#:global EmailGeneralToOverride {
# "check-certificates"="override@example.com";
-# "email-backup"="backup@example.com";
+# "backup-email"="backup@example.com";
#}
# Toggle this to disable symbols in notifications.