mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
backup-upload: 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
ce822a0276
commit
49d85c6def
1 changed files with 12 additions and 20 deletions
|
@ -100,30 +100,22 @@ $WaitFullyConnected;
|
|||
|
||||
# global-config-overlay
|
||||
:if ($BackupSendGlobalConfig = true) do={
|
||||
:local Config [ /system/script/get global-config-overlay source ];
|
||||
:local Size [ :len $Config ];
|
||||
# Do *NOT* use '/file/add ...' here, as it is limited to 4095 bytes!
|
||||
:execute script={ :put [ /system/script/get global-config-overlay source ]; } \
|
||||
file=($FilePath . ".conf");
|
||||
$WaitForFile ($FilePath . ".conf.txt");
|
||||
|
||||
:if ($Size <= 4095) {
|
||||
/file/add name=($FilePath . ".conf") contents=$Config;
|
||||
$WaitForFile ($FilePath . ".conf");
|
||||
|
||||
:do {
|
||||
/tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".conf") \
|
||||
user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf");
|
||||
: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");
|
||||
} else={
|
||||
$LogPrintExit2 warning $0 ("Creating config file not possible. Limit is 4kB, configuration has " . \
|
||||
$Size . " bytes.") false;
|
||||
: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; \
|
||||
|
|
Loading…
Reference in a new issue