mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 10:04:19 +02:00
rename script email-backup -> backup-email
This commit is contained in:
parent
8c39f41ffc
commit
95b17ab9a1
|
@ -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)
|
||||
|
|
80
backup-email
Normal file
80
backup-email
Normal file
|
@ -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 });
|
|
@ -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)
|
||||
|
||||
---
|
||||
|
|
54
doc/backup-email.md
Normal file
54
doc/backup-email.md
Normal file
|
@ -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)
|
|
@ -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).
|
|
@ -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)
|
||||
|
||||
---
|
||||
|
|
|
@ -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)
|
||||
|
||||
---
|
||||
|
|
80
email-backup
80
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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue