diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | backup-partition | 36 | ||||
-rw-r--r-- | doc/backup-cloud.md | 1 | ||||
-rw-r--r-- | doc/backup-email.md | 1 | ||||
-rw-r--r-- | doc/backup-partition.md | 45 | ||||
-rw-r--r-- | doc/backup-upload.md | 3 | ||||
-rw-r--r-- | doc/packages-update.md | 1 | ||||
-rw-r--r-- | global-config | 2 | ||||
-rw-r--r-- | global-config-overlay | 2 | ||||
-rw-r--r-- | global-config.changes | 1 | ||||
-rw-r--r-- | global-functions | 2 |
11 files changed, 91 insertions, 4 deletions
@@ -192,6 +192,7 @@ Available scripts * [Find and remove access list duplicates](doc/accesslist-duplicates.md) * [Upload backup to Mikrotik cloud](doc/backup-cloud.md) * [Send backup via e-mail](doc/backup-email.md) +* [Save configuration to fallback partition](doc/backup-partition.md) * [Upload backup to server](doc/backup-upload.md) * [Download packages for CAP upgrade from CAPsMAN](doc/capsman-download-packages.md) * [Run rolling CAP upgrades from CAPsMAN](doc/capsman-rolling-upgrade.md) diff --git a/backup-partition b/backup-partition new file mode 100644 index 0000000..c72c7f9 --- /dev/null +++ b/backup-partition @@ -0,0 +1,36 @@ +#!rsc by RouterOS +# RouterOS script: backup-partition +# Copyright (c) 2022 Christian Hesse <mail@eworm.de> +# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md +# +# provides: backup-script +# +# save configuration to fallback partition +# https://git.eworm.de/cgit/routeros-scripts/about/doc/backup-partition.md + +:local 0 "backup-partition"; +:global GlobalFunctionsReady; +:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } + +:global LogPrintExit2; + +:if ([ :len [ / partitions find ] ] < 2) do={ + $LogPrintExit2 error $0 ("Device does not have a fallback partition.") true; +} + +:local ActiveRunning [ / partitions find where active running ]; + +:if ([ :len $ActiveRunning ] < 1) do={ + $LogPrintExit2 error $0 ("Device is not running from active partition.") true; +} + +:local ActiveRunningVar [ / partitions get $ActiveRunning ]; + +:do { + / partitions save-config-to ($ActiveRunningVar->"fallback-to"); + $LogPrintExit2 info $0 ("Saved configuration to partition '" . \ + ($ActiveRunningVar->"fallback-to") . "'.") false; +} on-error={ + $LogPrintExit2 error $0 ("Failed saving configuration to partition '" . \ + ($ActiveRunningVar->"fallback-to") . "'!") true; +} diff --git a/doc/backup-cloud.md b/doc/backup-cloud.md index f3631ad..6a15688 100644 --- a/doc/backup-cloud.md +++ b/doc/backup-cloud.md @@ -55,6 +55,7 @@ See also -------- * [Send backup via e-mail](backup-email.md) +* [Save configuration to fallback partition](doc/backup-partition.md) * [Upload backup to server](backup-upload.md) --- diff --git a/doc/backup-email.md b/doc/backup-email.md index e6bed51..9c2edb5 100644 --- a/doc/backup-email.md +++ b/doc/backup-email.md @@ -46,6 +46,7 @@ See also -------- * [Upload backup to Mikrotik cloud](backup-cloud.md) +* [Save configuration to fallback partition](doc/backup-partition.md) * [Upload backup to server](backup-upload.md) --- diff --git a/doc/backup-partition.md b/doc/backup-partition.md new file mode 100644 index 0000000..c31c780 --- /dev/null +++ b/doc/backup-partition.md @@ -0,0 +1,45 @@ +Save configuration to fallback partition +======================================== + +[◀ Go back to main README](../README.md) + +> ℹ️ **Info**: This script can not be used on its own but requires the base +> installation. See [main README](../README.md) for details. + +Description +----------- + +This script saves the current configuration to fallback +[partition](https://wiki.mikrotik.com/wiki/Manual:Partitions). + +For this to work you need a device with sufficient flash storage that is +properly partitioned. + +Requirements and installation +----------------------------- + +Just install the script: + + $ScriptInstallUpdate backup-partition; + +Usage and invocation +-------------------- + +Just run the script: + + / system script run backup-partition; + +Creating a scheduler may be an option: + + / system scheduler add interval=1w name=backup-partition on-event="/ system script run backup-partition;" start-time=09:30:00; + +See also +-------- + +* [Upload backup to Mikrotik cloud](backup-cloud.md) +* [Send backup via e-mail](backup-email.md) +* [Upload backup to server](backup-upload.md) + +--- +[◀ Go back to main README](../README.md) +[▲ Go back to top](#top) diff --git a/doc/backup-upload.md b/doc/backup-upload.md index 6c12c82..08d64b0 100644 --- a/doc/backup-upload.md +++ b/doc/backup-upload.md @@ -69,8 +69,9 @@ Creating a scheduler may be an option: See also -------- -* [Send backup via e-mail](backup-email.md) * [Upload backup to Mikrotik cloud](backup-cloud.md) +* [Send backup via e-mail](backup-email.md) +* [Save configuration to fallback partition](doc/backup-partition.md) --- [◀ Go back to main README](../README.md) diff --git a/doc/packages-update.md b/doc/packages-update.md index 0007acc..243e72b 100644 --- a/doc/packages-update.md +++ b/doc/packages-update.md @@ -43,6 +43,7 @@ See also * [Notify on RouterOS update](check-routeros-update.md) * [Upload backup to Mikrotik cloud](backup-cloud.md) * [Send backup via e-mail](backup-email.md) +* [Save configuration to fallback partition](doc/backup-partition.md) * [Upload backup to server](backup-upload.md) * [Automatically upgrade firmware and reboot](firmware-upgrade-reboot.md) diff --git a/global-config b/global-config index a664cb6..d6509e0 100644 --- a/global-config +++ b/global-config @@ -8,7 +8,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! -:global GlobalConfigVersion 78; +:global GlobalConfigVersion 79; # This is used for DNS and backup file. :global Domain "example.com"; diff --git a/global-config-overlay b/global-config-overlay index 946559e..b5be658 100644 --- a/global-config-overlay +++ b/global-config-overlay @@ -8,7 +8,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! # Comment or remove to disable news and change notifications. -:global GlobalConfigVersion 78; +:global GlobalConfigVersion 79; # Use branch routeros-v6 with RouterOS v6: :global ScriptUpdatesUrlSuffix "\?h=routeros-v6"; diff --git a/global-config.changes b/global-config.changes index 2764d78..5f9ddcc 100644 --- a/global-config.changes +++ b/global-config.changes @@ -82,6 +82,7 @@ 76="Added an option to suppress notifications on host down with 'netwatch-notify'."; 77="Introduced new script 'firmware-upgrade-reboot'. Handle with care!"; 78="New documentation is online for notifications via Telegram & Matrix, variable inspection, ip address calculation and running scripts once."; + 79="Introduced new script 'backup-partition' to save configuration to fallback partition."; }; # Migration steps to be applied on script updates diff --git a/global-functions b/global-functions index 91297b4..05a111c 100644 --- a/global-functions +++ b/global-functions @@ -8,7 +8,7 @@ # https://git.eworm.de/cgit/routeros-scripts/about/ # expected configuration version -:global ExpectedConfigVersion 78; +:global ExpectedConfigVersion 79; # global variables not to be changed by user :global GlobalFunctionsReady false; |