mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 10:04:19 +02:00
rename script cloud-backup -> backup-cloud
This commit is contained in:
parent
57c80dc2a4
commit
8c39f41ffc
|
@ -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)
|
||||
|
|
58
backup-cloud
Normal file
58
backup-cloud
Normal file
|
@ -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;
|
||||
}
|
58
cloud-backup
58
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
|
||||
|
|
|
@ -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"
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
54
doc/backup-cloud.md
Normal file
54
doc/backup-cloud.md
Normal file
|
@ -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)
|
|
@ -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).
|
||||
|
|
|
@ -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)
|
||||
|
||||
---
|
||||
|
|
|
@ -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!
|
||||
|
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue