aboutsummaryrefslogtreecommitdiffstats
path: root/backup-partition.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-05-22 09:26:13 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-05-23 12:11:41 +0200
commit51331ea2acd5f5563ed3641090bbb7f2104d3e96 (patch)
treed45efbc3a634bfab96f9bcc1802776967c1db265 /backup-partition.rsc
parent0a46fb536f929f3248085072979b7acfe119dbd5 (diff)
backup-partition: support RouterOS copy-over...
... when run interactively from CLI.
Diffstat (limited to 'backup-partition.rsc')
-rw-r--r--backup-partition.rsc17
1 files changed, 17 insertions, 0 deletions
diff --git a/backup-partition.rsc b/backup-partition.rsc
index fc186c0..9eeb1ae 100644
--- a/backup-partition.rsc
+++ b/backup-partition.rsc
@@ -18,6 +18,7 @@
:global PackagesUpdateBackupFailure;
:global LogPrint;
+ :global ScriptFromTerminal;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
@@ -41,6 +42,22 @@
:local FallbackTo [ /partitions/get $ActiveRunning fallback-to ];
+ :if ([ /partitions/get $ActiveRunning version ] != [ /partitions/get $FallbackTo version]) do={
+ :if ([ $ScriptFromTerminal $ScriptName ] = true) do={
+ :put ("The partitions have different RouterOS versions. Copy over to '" . $FallbackTo . "'? [y/N]");
+ :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={
+ :do {
+ /partitions/copy-to $FallbackTo;
+ $LogPrint info $ScriptName ("Copied RouterOS to partition '" . $FallbackTo . "'.");
+ } on-error={
+ $LogPrint error $ScriptName ("Failed copying RouterOS to partition '" . $FallbackTo . "'!");
+ :set PackagesUpdateBackupFailure true;
+ :error false;
+ }
+ }
+ }
+ }
+
:do {
/system/scheduler/add start-time=startup name="running-from-backup-partition" \
on-event=(":log warning (\"Running from partition '\" . " . \