Files
eworm-de-routeros-scripts/cloud-backup
T

38 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2019-06-14 14:59:49 +02:00
#!rsc
# RouterOS script: cloud-backup
2020-01-01 17:00:39 +01:00
# Copyright (c) 2013-2020 Christian Hesse <[email protected]>
2020-06-19 22:17:42 +02:00
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
2019-06-14 14:59:49 +02:00
#
# upload backup to MikroTik cloud
2020-03-27 21:42:33 +01:00
# https://git.eworm.de/cgit/routeros-scripts/about/doc/cloud-backup.md
2019-06-14 14:59:49 +02:00
:global BackupPassword;
2020-02-28 15:26:26 +01:00
:global Identity;
2019-06-14 14:59:49 +02:00
:global DeviceInfo;
2020-04-03 17:30:00 +02:00
:global LogPrintExit;
2019-06-14 14:59:49 +02:00
:global SendNotification;
:do {
# we are not interested in output, but print without count-only is
# required to fetch information from cloud
/ system backup cloud print as-value;
:if ([ / system backup cloud print count-only ] > 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;
2019-06-14 14:59:49 +02:00
}
:local Cloud [ / system backup cloud get ([ find ]->0) ];
$SendNotification "Cloud backup" \
("Uploaded backup for " . $Identity . " to cloud.\n\n" . \
[ $DeviceInfo ] . "\n\n" . \
2019-06-14 14:59:49 +02:00
"Name: " . $Cloud->"name" . "\n" . \
"Size: " . $Cloud->"size" . "\n" . \
2019-08-18 19:14:17 +02:00
"Download key: " . $Cloud->"secret-download-key") "" "true";
2019-06-14 14:59:49 +02:00
} on-error={
2020-04-03 17:30:00 +02:00
$LogPrintExit error ("Failed uploading backup for " . $Identity . " to cloud.") false;
2019-06-14 14:59:49 +02:00
}