aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-01-05 22:36:49 +0100
committerGravatar Christian Hesse <mail@eworm.de>2022-01-06 08:19:58 +0100
commit8c39f41ffcf3af7fe6d8b4091db5791756f59879 (patch)
treed5fdd47c6c965849ab05b20c298fddce59ba6f5c
parent57c80dc2a42280c1a8d1f2c7de8d73a3e03190bc (diff)
rename script cloud-backup -> backup-cloud
-rw-r--r--README.md2
-rw-r--r--backup-cloud58
-rw-r--r--cloud-backup58
-rw-r--r--doc/backup-cloud.d/notification.svg (renamed from doc/cloud-backup.d/notification.svg)2
-rw-r--r--doc/backup-cloud.md54
-rw-r--r--doc/cloud-backup.md55
-rw-r--r--doc/email-backup.md2
-rw-r--r--doc/log-forward.d/notification.svg2
-rw-r--r--doc/upload-backup.md2
9 files changed, 119 insertions, 116 deletions
diff --git a/README.md b/README.md
index f55a14b..f14403d 100644
--- a/README.md
+++ b/README.md
@@ -185,6 +185,7 @@ Available scripts
-----------------
* [Find and remove access list duplicates](doc/accesslist-duplicates.md)
+* [Upload backup to Mikrotik cloud](doc/backup-cloud.md)
* [Download packages for CAP upgrade from CAPsMAN](doc/capsman-download-packages.md)
* [Run rolling CAP upgrades from CAPsMAN](doc/capsman-rolling-upgrade.md)
* [Renew locally issued certificates](doc/certificate-renew-issued.md)
@@ -192,7 +193,6 @@ Available scripts
* [Notify about health state](doc/check-health.md)
* [Notify on LTE firmware upgrade](doc/check-lte-firmware-upgrade.md)
* [Notify on RouterOS update](doc/check-routeros-update.md)
-* [Upload backup to Mikrotik cloud](doc/cloud-backup.md)
* [Collect MAC addresses in wireless access list](doc/collect-wireless-mac.md)
* [Use wireless network with daily psk](doc/daily-psk.md)
* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md)
diff --git a/backup-cloud b/backup-cloud
new file mode 100644
index 0000000..d1d9f14
--- /dev/null
+++ b/backup-cloud
@@ -0,0 +1,58 @@
+#!rsc by RouterOS
+# RouterOS script: backup-cloud
+# Copyright (c) 2013-2022 Christian Hesse <mail@eworm.de>
+# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+#
+# provides: backup-script
+#
+# upload backup to MikroTik cloud
+# https://git.eworm.de/cgit/routeros-scripts/about/doc/backup-cloud.md
+
+:local 0 "backup-cloud";
+:global GlobalFunctionsReady;
+:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+
+:global BackupPassword;
+:global BackupRandomDelay;
+:global Identity;
+
+:global DeviceInfo;
+:global LogPrintExit2;
+:global RandomDelay;
+:global ScriptFromTerminal;
+:global SendNotification2;
+:global SymbolForNotification;
+:global WaitFullyConnected;
+
+$WaitFullyConnected;
+
+:if ([ $ScriptFromTerminal $0 ] = false && $BackupRandomDelay > 0) do={
+ $RandomDelay $BackupRandomDelay;
+}
+
+:do {
+ # we are not interested in output, but print is
+ # required to fetch information from cloud
+ / system backup cloud print as-value;
+ :if ([ :len [ / system backup cloud find ] ] > 0) do={
+ / system backup cloud upload-file action=create-and-upload \
+ password=$BackupPassword replace=[ get ([ find ]->0) name ];
+ } else={
+ / system backup cloud upload-file action=create-and-upload \
+ password=$BackupPassword;
+ }
+ :local Cloud [ / system backup cloud get ([ find ]->0) ];
+
+ $SendNotification2 ({ origin=$0; \
+ subject=([ $SymbolForNotification "floppy-disk,cloud" ] . "Cloud backup"); \
+ message=("Uploaded backup for " . $Identity . " to cloud.\n\n" . \
+ [ $DeviceInfo ] . "\n\n" . \
+ "Name: " . $Cloud->"name" . "\n" . \
+ "Size: " . $Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)\n" . \
+ "Download key: " . $Cloud->"secret-download-key"); silent=true });
+} on-error={
+ $SendNotification2 ({ origin=$0; \
+ subject=([ $SymbolForNotification "warning-sign" ] . "Cloud backup failed"); \
+ message=("Failed uploading backup for " . $Identity . " to cloud!\n\n" . [ $DeviceInfo ]) });
+ $LogPrintExit2 error $0 ("Failed uploading backup for " . $Identity . " to cloud!") true;
+}
diff --git a/cloud-backup b/cloud-backup
index ab2cf7c..2c48f07 100644
--- a/cloud-backup
+++ b/cloud-backup
@@ -1,58 +1,2 @@
#!rsc by RouterOS
-# RouterOS script: cloud-backup
-# Copyright (c) 2013-2022 Christian Hesse <mail@eworm.de>
-# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
-#
-# provides: backup-script
-#
-# upload backup to MikroTik cloud
-# https://git.eworm.de/cgit/routeros-scripts/about/doc/cloud-backup.md
-
-:local 0 "cloud-backup";
-:global GlobalFunctionsReady;
-:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-
-:global BackupPassword;
-:global BackupRandomDelay;
-:global Identity;
-
-:global DeviceInfo;
-:global LogPrintExit2;
-:global RandomDelay;
-:global ScriptFromTerminal;
-:global SendNotification2;
-:global SymbolForNotification;
-:global WaitFullyConnected;
-
-$WaitFullyConnected;
-
-:if ([ $ScriptFromTerminal $0 ] = false && $BackupRandomDelay > 0) do={
- $RandomDelay $BackupRandomDelay;
-}
-
-:do {
- # we are not interested in output, but print is
- # required to fetch information from cloud
- / system backup cloud print as-value;
- :if ([ :len [ / system backup cloud find ] ] > 0) do={
- / system backup cloud upload-file action=create-and-upload \
- password=$BackupPassword replace=[ get ([ find ]->0) name ];
- } else={
- / system backup cloud upload-file action=create-and-upload \
- password=$BackupPassword;
- }
- :local Cloud [ / system backup cloud get ([ find ]->0) ];
-
- $SendNotification2 ({ origin=$0; \
- subject=([ $SymbolForNotification "floppy-disk,cloud" ] . "Cloud backup"); \
- message=("Uploaded backup for " . $Identity . " to cloud.\n\n" . \
- [ $DeviceInfo ] . "\n\n" . \
- "Name: " . $Cloud->"name" . "\n" . \
- "Size: " . $Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)\n" . \
- "Download key: " . $Cloud->"secret-download-key"); silent=true });
-} on-error={
- $SendNotification2 ({ origin=$0; \
- subject=([ $SymbolForNotification "warning-sign" ] . "Cloud backup failed"); \
- message=("Failed uploading backup for " . $Identity . " to cloud!\n\n" . [ $DeviceInfo ]) });
- $LogPrintExit2 error $0 ("Failed uploading backup for " . $Identity . " to cloud!") true;
-}
+# dummy for migration
diff --git a/doc/cloud-backup.d/notification.svg b/doc/backup-cloud.d/notification.svg
index 8b84b8f..b023e50 100644
--- a/doc/cloud-backup.d/notification.svg
+++ b/doc/backup-cloud.d/notification.svg
@@ -6,7 +6,7 @@
version="1.1"
id="svg8"
inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
- sodipodi:docname="cloud-backup.svg"
+ sodipodi:docname="backup-cloud.svg"
inkscape:export-filename="logo.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
diff --git a/doc/backup-cloud.md b/doc/backup-cloud.md
new file mode 100644
index 0000000..18b9ec1
--- /dev/null
+++ b/doc/backup-cloud.md
@@ -0,0 +1,54 @@
+Upload backup to Mikrotik cloud
+===============================
+
+[◀ Go back to main README](../README.md)
+
+🛈 This script can not be used on its own but requires the base installation.
+See [main README](../README.md) for details.
+
+Description
+-----------
+
+This script uploads [binary backup to Mikrotik cloud](https://wiki.mikrotik.com/wiki/Manual:IP/Cloud#Backup).
+
+### Sample notification
+
+![backup-cloud notification](backup-cloud.d/notification.svg)
+
+Requirements and installation
+-----------------------------
+
+Just install the script:
+
+ $ScriptInstallUpdate backup-cloud;
+
+Configuration
+-------------
+
+The configuration goes to `global-config-overlay`, these are the parameters:
+
+* `BackupPassword`: password to encrypt the backup with
+* `BackupRandomDelay`: delay up to amount of seconds when run from scheduler
+
+Also notification settings are required for e-mail, matrix and/or telegram.
+
+Usage and invocation
+--------------------
+
+Just run the script:
+
+ / system script run backup-cloud;
+
+Creating a scheduler may be an option:
+
+ / system scheduler add interval=1w name=backup-cloud on-event="/ system script run backup-cloud;" start-time=09:20:00;
+
+See also
+--------
+
+* [Send backup via e-mail](email-backup.md)
+* [Upload backup to server](upload-backup.md)
+
+---
+[◀ Go back to main README](../README.md)
+[▲ Go back to top](#top)
diff --git a/doc/cloud-backup.md b/doc/cloud-backup.md
index 7522bc1..e161cfa 100644
--- a/doc/cloud-backup.md
+++ b/doc/cloud-backup.md
@@ -1,54 +1 @@
-Upload backup to Mikrotik cloud
-===============================
-
-[◀ Go back to main README](../README.md)
-
-🛈 This script can not be used on its own but requires the base installation.
-See [main README](../README.md) for details.
-
-Description
------------
-
-This script uploads [binary backup to Mikrotik cloud](https://wiki.mikrotik.com/wiki/Manual:IP/Cloud#Backup).
-
-### Sample notification
-
-![cloud-backup notification](cloud-backup.d/notification.svg)
-
-Requirements and installation
------------------------------
-
-Just install the script:
-
- $ScriptInstallUpdate cloud-backup;
-
-Configuration
--------------
-
-The configuration goes to `global-config-overlay`, these are the parameters:
-
-* `BackupPassword`: password to encrypt the backup with
-* `BackupRandomDelay`: delay up to amount of seconds when run from scheduler
-
-Also notification settings are required for e-mail, matrix and/or telegram.
-
-Usage and invocation
---------------------
-
-Just run the script:
-
- / system script run cloud-backup;
-
-Creating a scheduler may be an option:
-
- / system scheduler add interval=1w name=cloud-backup on-event="/ system script run cloud-backup;" start-time=09:20:00;
-
-See also
---------
-
-* [Send backup via e-mail](email-backup.md)
-* [Upload backup to server](upload-backup.md)
-
----
-[◀ Go back to main README](../README.md)
-[▲ Go back to top](#top)
+This script has been renamed. Please see [backup-cloud](backup-cloud.md).
diff --git a/doc/email-backup.md b/doc/email-backup.md
index 85d50bd..bb48e9d 100644
--- a/doc/email-backup.md
+++ b/doc/email-backup.md
@@ -46,7 +46,7 @@ Creating a scheduler may be an option:
See also
--------
-* [Upload backup to Mikrotik cloud](cloud-backup.md)
+* [Upload backup to Mikrotik cloud](backup-cloud.md)
* [Upload backup to server](upload-backup.md)
---
diff --git a/doc/log-forward.d/notification.svg b/doc/log-forward.d/notification.svg
index b3389fe..373144b 100644
--- a/doc/log-forward.d/notification.svg
+++ b/doc/log-forward.d/notification.svg
@@ -170,7 +170,7 @@
</tspan><tspan
x="180"
y="86.082811"
- id="tspan2327"> ● 13:24:02 script;error cloud-backup: Failed uploading backup </tspan><tspan
+ id="tspan2327"> ● 13:24:02 script;error backup-cloud: Failed uploading backup </tspan><tspan
x="180"
y="101.08281"
id="tspan2329">for MikroTik to cloud!
diff --git a/doc/upload-backup.md b/doc/upload-backup.md
index 9566853..203f7f6 100644
--- a/doc/upload-backup.md
+++ b/doc/upload-backup.md
@@ -63,7 +63,7 @@ See also
--------
* [Send backup via e-mail](email-backup.md)
-* [Upload backup to Mikrotik cloud](cloud-backup.md)
+* [Upload backup to Mikrotik cloud](backup-cloud.md)
---
[◀ Go back to main README](../README.md)