mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
Merge branch 'backup-g-c-o' into next
This commit is contained in:
commit
aee42d31e1
14
backup-email
14
backup-email
|
@ -16,6 +16,7 @@
|
||||||
:global BackupRandomDelay;
|
:global BackupRandomDelay;
|
||||||
:global BackupSendBinary;
|
:global BackupSendBinary;
|
||||||
:global BackupSendExport;
|
:global BackupSendExport;
|
||||||
|
:global BackupSendGlobalConfig;
|
||||||
:global Domain;
|
:global Domain;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ $WaitFullyConnected;
|
||||||
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
|
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
|
||||||
:local FilePath ($DirName . "/" . $FileName);
|
:local FilePath ($DirName . "/" . $FileName);
|
||||||
:local BackupFile "none";
|
:local BackupFile "none";
|
||||||
|
:local ExportFile "none";
|
||||||
:local ConfigFile "none";
|
:local ConfigFile "none";
|
||||||
:local Attach ({});
|
:local Attach ({});
|
||||||
|
|
||||||
|
@ -69,10 +71,19 @@ $WaitFullyConnected;
|
||||||
:if ($BackupSendExport = true) do={
|
:if ($BackupSendExport = true) do={
|
||||||
/export terse show-sensitive file=$FilePath;
|
/export terse show-sensitive file=$FilePath;
|
||||||
$WaitForFile ($FilePath . ".rsc");
|
$WaitForFile ($FilePath . ".rsc");
|
||||||
:set ConfigFile ($FileName . ".rsc");
|
:set ExportFile ($FileName . ".rsc");
|
||||||
:set Attach ($Attach, ($FilePath . ".rsc"));
|
:set Attach ($Attach, ($FilePath . ".rsc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# global-config-overlay
|
||||||
|
:if ($BackupSendGlobalConfig = true) do={
|
||||||
|
:execute script={ / } file=($FilePath . ".conf");
|
||||||
|
$WaitForFile ($FilePath . ".conf.txt");
|
||||||
|
/file/set ($FilePath . ".conf.txt") contents=[ /system/script/get global-config-overlay source ];
|
||||||
|
:set ConfigFile ($FileName . ".conf.txt");
|
||||||
|
:set Attach ($Attach, ($FilePath . ".conf.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
# send email with status and files
|
# send email with status and files
|
||||||
$SendEMail2 ({ origin=$0; \
|
$SendEMail2 ({ origin=$0; \
|
||||||
subject=([ $SymbolForNotification "floppy-disk,incoming-envelope" ] . \
|
subject=([ $SymbolForNotification "floppy-disk,incoming-envelope" ] . \
|
||||||
|
@ -81,6 +92,7 @@ $SendEMail2 ({ origin=$0; \
|
||||||
$Identity . ".\n\n" . \
|
$Identity . ".\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
"Backup file: " . $BackupFile . "\n" . \
|
"Backup file: " . $BackupFile . "\n" . \
|
||||||
|
"Export file: " . $ExportFile . "\n" . \
|
||||||
"Config file: " . $ConfigFile); \
|
"Config file: " . $ConfigFile); \
|
||||||
attach=$Attach; remove-attach=true });
|
attach=$Attach; remove-attach=true });
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
:global BackupRandomDelay;
|
:global BackupRandomDelay;
|
||||||
:global BackupSendBinary;
|
:global BackupSendBinary;
|
||||||
:global BackupSendExport;
|
:global BackupSendExport;
|
||||||
|
:global BackupSendGlobalConfig;
|
||||||
:global BackupUploadPass;
|
:global BackupUploadPass;
|
||||||
:global BackupUploadUrl;
|
:global BackupUploadUrl;
|
||||||
:global BackupUploadUser;
|
:global BackupUploadUser;
|
||||||
|
@ -50,6 +51,7 @@ $WaitFullyConnected;
|
||||||
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
|
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
|
||||||
:local FilePath ($DirName . "/" . $FileName);
|
:local FilePath ($DirName . "/" . $FileName);
|
||||||
:local BackupFile "none";
|
:local BackupFile "none";
|
||||||
|
:local ExportFile "none";
|
||||||
:local ConfigFile "none";
|
:local ConfigFile "none";
|
||||||
:local Failed 0;
|
:local Failed 0;
|
||||||
|
|
||||||
|
@ -83,16 +85,35 @@ $WaitFullyConnected;
|
||||||
:do {
|
:do {
|
||||||
/tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".rsc") \
|
/tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".rsc") \
|
||||||
user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".rsc");
|
user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".rsc");
|
||||||
:set ConfigFile ($FileName . ".rsc");
|
:set ExportFile ($FileName . ".rsc");
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 error $0 ("Uploading configuration export failed!") false;
|
$LogPrintExit2 error $0 ("Uploading configuration export failed!") false;
|
||||||
:set ConfigFile "failed";
|
:set ExportFile "failed";
|
||||||
:set Failed 1;
|
:set Failed 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/file/remove ($FilePath . ".rsc");
|
/file/remove ($FilePath . ".rsc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# global-config-overlay
|
||||||
|
:if ($BackupSendGlobalConfig = true) do={
|
||||||
|
:execute script={ / } file=($FilePath . ".conf");
|
||||||
|
$WaitForFile ($FilePath . ".conf.txt");
|
||||||
|
/file/set ($FilePath . ".conf.txt") contents=[ /system/script/get global-config-overlay source ];
|
||||||
|
|
||||||
|
:do {
|
||||||
|
/tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".conf") \
|
||||||
|
user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf.txt");
|
||||||
|
:set ConfigFile ($FileName . ".conf");
|
||||||
|
} on-error={
|
||||||
|
$LogPrintExit2 error $0 ("Uploading global-config-overlay failed!") false;
|
||||||
|
:set ConfigFile "failed";
|
||||||
|
:set Failed 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/file/remove ($FilePath . ".conf.txt");
|
||||||
|
}
|
||||||
|
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=[ $IfThenElse ($Failed > 0) \
|
subject=[ $IfThenElse ($Failed > 0) \
|
||||||
([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Backup & Config upload with failure") \
|
([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Backup & Config upload with failure") \
|
||||||
|
@ -100,6 +121,7 @@ $SendNotification2 ({ origin=$0; \
|
||||||
message=("Backup and config export upload for " . $Identity . ".\n\n" . \
|
message=("Backup and config export upload for " . $Identity . ".\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
"Backup file: " . $BackupFile . "\n" . \
|
"Backup file: " . $BackupFile . "\n" . \
|
||||||
|
"Export file: " . $ExportFile . "\n" . \
|
||||||
"Config file: " . $ConfigFile); silent=true });
|
"Config file: " . $ConfigFile); silent=true });
|
||||||
|
|
||||||
:if ($Failed = 1) do={
|
:if ($Failed = 1) do={
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
# This defines what backups to generate and what password to use.
|
# This defines what backups to generate and what password to use.
|
||||||
:global BackupSendBinary false;
|
:global BackupSendBinary false;
|
||||||
:global BackupSendExport true;
|
:global BackupSendExport true;
|
||||||
|
:global BackupSendGlobalConfig true;
|
||||||
:global BackupPassword "v3ry-s3cr3t";
|
:global BackupPassword "v3ry-s3cr3t";
|
||||||
:global BackupRandomDelay 0;
|
:global BackupRandomDelay 0;
|
||||||
# These credentials are used to upload backup and config export files.
|
# These credentials are used to upload backup and config export files.
|
||||||
|
|
|
@ -101,6 +101,7 @@
|
||||||
90="Chat with your router! Introduced 'telegram-chat' to chat via Telegram bot and send commands to your router.";
|
90="Chat with your router! Introduced 'telegram-chat' to chat via Telegram bot and send commands to your router.";
|
||||||
91="Dropped check for CAP in 'check-routeros-update' to solve issues with wifiwave2 package.";
|
91="Dropped check for CAP in 'check-routeros-update' to solve issues with wifiwave2 package.";
|
||||||
92="Made qr-code url configurable for 'daily-psk'.";
|
92="Made qr-code url configurable for 'daily-psk'.";
|
||||||
|
93="Added support to backup global-config-overlay in 'backup-email' and 'backup-upload'.";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Migration steps to be applied on script updates
|
# Migration steps to be applied on script updates
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
:local 0 "global-functions";
|
:local 0 "global-functions";
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 92;
|
:global ExpectedConfigVersion 93;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
|
Loading…
Reference in a new issue