mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-08-04 02:05:01 +02:00
backup-partition: support copy before feature update
This commit is contained in:
parent
6cbe13a135
commit
affa118161
3 changed files with 30 additions and 3 deletions
|
@ -15,11 +15,13 @@
|
|||
:do {
|
||||
:local ScriptName [ :jobname ];
|
||||
|
||||
:global BackupPartitionCopyBeforeFeatureUpdate;
|
||||
:global PackagesUpdateBackupFailure;
|
||||
|
||||
:global LogPrint;
|
||||
:global ScriptFromTerminal;
|
||||
:global ScriptLock;
|
||||
:global VersionToNum;
|
||||
|
||||
:local CopyTo do={
|
||||
:local ScriptName [ :tostr $1 ];
|
||||
|
@ -67,6 +69,17 @@
|
|||
:error false;
|
||||
}
|
||||
}
|
||||
} else={
|
||||
:local Update [ /system/package/update/get ];
|
||||
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
|
||||
:local NumLatest [ $VersionToNum ($Update->"latest-version") ];
|
||||
:if ($BackupPartitionCopyBeforeFeatureUpdate = true && $NumLatest > 0 && \
|
||||
($NumInstalled & 0xffff0000) != ($NumLatest & 0xffff0000)) do={
|
||||
:if ([ $CopyTo $ScriptName $FallbackTo ] = false) do={
|
||||
:set PackagesUpdateBackupFailure true;
|
||||
:error false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ Description
|
|||
|
||||
This script saves the current configuration to fallback
|
||||
[partition](https://wiki.mikrotik.com/wiki/Manual:Partitions).
|
||||
It can also copy-over the RouterOS installation when run interactively.
|
||||
It can also copy-over the RouterOS installation when run interactively
|
||||
or just before a feature update.
|
||||
|
||||
For this to work you need a device with sufficient flash storage that is
|
||||
properly partitioned.
|
||||
|
@ -29,8 +30,7 @@ added in the backup partition's configuration. You may want to use
|
|||
|
||||
> ⚠️ **Warning**: By default only the configuration is saved to backup
|
||||
> partition. Every now and then you should copy your installation over
|
||||
> for a recent RouterOS version! For that run the script from terminal
|
||||
> manually.
|
||||
> for a recent RouterOS version! See below for options.
|
||||
|
||||
Requirements and installation
|
||||
-----------------------------
|
||||
|
@ -39,6 +39,18 @@ Just install the script:
|
|||
|
||||
$ScriptInstallUpdate backup-partition;
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
The configuration goes to `global-config-overlay`, the only parameter is:
|
||||
|
||||
* `BackupPartitionCopyBeforeFeatureUpdate`: copy-over the RouterOS
|
||||
installation when a feature update is pending
|
||||
|
||||
> ℹ️ **Info**: Copy relevant configuration from
|
||||
> [`global-config`](../global-config.rsc) (the one without `-overlay`) to
|
||||
> your local `global-config-overlay` and modify it to your specific needs.
|
||||
|
||||
Usage and invocation
|
||||
--------------------
|
||||
|
||||
|
|
|
@ -85,6 +85,8 @@
|
|||
:global BackupUploadUrl "sftp://example.com/backup/";
|
||||
:global BackupUploadUser "mikrotik";
|
||||
:global BackupUploadPass "v3ry-s3cr3t";
|
||||
# Copy the RouterOS installation to backup partition before feature update.
|
||||
:global BackupPartitionCopyBeforeFeatureUpdate false;
|
||||
|
||||
# This defines the settings for firewall address-lists (fw-addr-lists).
|
||||
:global FwAddrLists {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue