mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-23 20:34:27 +02:00
backup-email: revert changes, add comment with warning
Turned out that using `/file/add ...` introduced a regression. Accessing (reading and writing) file contents is limited to 4095 bytes. This limitation does not exist for `:execute script=... file=...`, so keep the old code. Also add a comment with warning.
This commit is contained in:
parent
f099c2c9ea
commit
ce822a0276
1 changed files with 8 additions and 23 deletions
|
@ -23,7 +23,6 @@
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
:global DeviceInfo;
|
:global DeviceInfo;
|
||||||
:global FormatLine;
|
:global FormatLine;
|
||||||
:global IfThenElse;
|
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global MkDir;
|
:global MkDir;
|
||||||
:global RandomDelay;
|
:global RandomDelay;
|
||||||
|
@ -58,7 +57,6 @@ $WaitFullyConnected;
|
||||||
:local ExportFile "none";
|
:local ExportFile "none";
|
||||||
:local ConfigFile "none";
|
:local ConfigFile "none";
|
||||||
:local Attach ({});
|
:local Attach ({});
|
||||||
:local Failed 0;
|
|
||||||
|
|
||||||
:if ([ $MkDir $DirName ] = false) do={
|
:if ([ $MkDir $DirName ] = false) do={
|
||||||
$LogPrintExit2 error $0 ("Failed creating directory!") true;
|
$LogPrintExit2 error $0 ("Failed creating directory!") true;
|
||||||
|
@ -82,27 +80,18 @@ $WaitFullyConnected;
|
||||||
|
|
||||||
# global-config-overlay
|
# global-config-overlay
|
||||||
:if ($BackupSendGlobalConfig = true) do={
|
:if ($BackupSendGlobalConfig = true) do={
|
||||||
:local Config [ /system/script/get global-config-overlay source ];
|
# Do *NOT* use '/file/add ...' here, as it is limited to 4095 bytes!
|
||||||
:local Size [ :len $Config ];
|
:execute script={ :put [ /system/script/get global-config-overlay source ]; } \
|
||||||
|
file=($FilePath . ".conf");
|
||||||
:if ($Size <= 4095) {
|
$WaitForFile ($FilePath . ".conf.txt");
|
||||||
/file/add name=($FilePath . ".conf") contents=$Config;
|
:set ConfigFile ($FileName . ".conf.txt");
|
||||||
$WaitForFile ($FilePath . ".conf");
|
:set Attach ($Attach, ($FilePath . ".conf.txt"));
|
||||||
:set ConfigFile ($FileName . ".conf");
|
|
||||||
:set Attach ($Attach, ($FilePath . ".conf"));
|
|
||||||
} else={
|
|
||||||
$LogPrintExit2 warning $0 ("Creating config file not possible. Limit is 4kB, configuration has " . \
|
|
||||||
$Size . " bytes.") false;
|
|
||||||
:set ConfigFile "failed";
|
|
||||||
:set Failed 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# send email with status and files
|
# send email with status and files
|
||||||
$SendEMail2 ({ origin=$0; \
|
$SendEMail2 ({ origin=$0; \
|
||||||
subject=[ $IfThenElse ($Failed > 0) \
|
subject=([ $SymbolForNotification "floppy-disk,incoming-envelope" ] . \
|
||||||
([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Backup & Config with failure") \
|
"Backup & Config"); \
|
||||||
([ $SymbolForNotification "floppy-disk,incoming-envelope" ] . "Backup & Config") ]; \
|
|
||||||
message=("See attached files for backup and config export for " . \
|
message=("See attached files for backup and config export for " . \
|
||||||
$Identity . ".\n\n" . \
|
$Identity . ".\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
|
@ -120,7 +109,3 @@ $SendEMail2 ({ origin=$0; \
|
||||||
:delay 1s;
|
:delay 1s;
|
||||||
:set I ($I + 1);
|
:set I ($I + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($Failed = 1) do={
|
|
||||||
:error "An error occured!";
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue