mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
email-backup: support cloud backup
This commit is contained in:
parent
be68c739a8
commit
6f606f9ca5
2 changed files with 30 additions and 7 deletions
32
email-backup
32
email-backup
|
@ -10,14 +10,18 @@
|
||||||
:global "email-backup-cc";
|
:global "email-backup-cc";
|
||||||
:global "backup-send-binary";
|
:global "backup-send-binary";
|
||||||
:global "backup-send-export";
|
:global "backup-send-export";
|
||||||
|
:global "backup-cloud";
|
||||||
:global "backup-password";
|
:global "backup-password";
|
||||||
|
|
||||||
:if ($"backup-send-binary" = false && $"backup-send-export" = false) do={
|
:if ($"backup-send-binary" != true && \
|
||||||
|
$"backup-send-export" != true && \
|
||||||
|
$"backup-cloud" != true) do={
|
||||||
:error ("Configured to send neither backup nor config export.");
|
:error ("Configured to send neither backup nor config export.");
|
||||||
}
|
}
|
||||||
|
|
||||||
# filename based on identity
|
# filename based on identity
|
||||||
:local filename ($identity . "." . $domain);
|
:local filename ($identity . "." . $domain);
|
||||||
|
:local cloudstatus $"backup-cloud";
|
||||||
:local attach [ :toarray "" ];
|
:local attach [ :toarray "" ];
|
||||||
|
|
||||||
# get some system information
|
# get some system information
|
||||||
|
@ -26,19 +30,36 @@
|
||||||
:local channel [ / system package update get channel ];
|
:local channel [ / system package update get channel ];
|
||||||
:local installedversion [ / system package update get installed-version ];
|
:local installedversion [ / system package update get installed-version ];
|
||||||
|
|
||||||
# create binary backup
|
# binary backup
|
||||||
|
:if ($"backup-send-binary" = true || \
|
||||||
|
$"backup-cloud" = true) do={
|
||||||
|
/ system backup save encryption=aes-sha256 name=$filename password=$"backup-password";
|
||||||
|
|
||||||
|
# attach to mail
|
||||||
:if ($"backup-send-binary" = true) do={
|
:if ($"backup-send-binary" = true) do={
|
||||||
/ system backup save name=$filename password=$"backup-password";
|
|
||||||
:set attach ( $attach, ($filename . ".backup") );
|
:set attach ( $attach, ($filename . ".backup") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# upload to cloud
|
||||||
|
:if ($"backup-cloud" = true) do={
|
||||||
|
:do {
|
||||||
|
:if ([ / system backup cloud print count-only ] > 0) do={
|
||||||
|
/ system backup cloud remove-file [ find ];
|
||||||
|
}
|
||||||
|
/ system backup cloud upload-file action=upload src-file=($filename . ".backup");
|
||||||
|
} on-error={
|
||||||
|
:set cloudstatus "failed";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# create configuration export
|
# create configuration export
|
||||||
:if ($"backup-send-export" = true) do={
|
:if ($"backup-send-export" = true) do={
|
||||||
/ export terse file=$filename;
|
/ export terse file=$filename;
|
||||||
:set attach ( $attach, ($filename . ".rsc") );
|
:set attach ( $attach, ($filename . ".rsc") );
|
||||||
}
|
}
|
||||||
|
|
||||||
# email files
|
# send email with status and files
|
||||||
/ tool e-mail send to=$"email-backup-to" cc=$"email-backup-cc" \
|
/ tool e-mail send to=$"email-backup-to" cc=$"email-backup-cc" \
|
||||||
subject=("[" . $identity . "] Backup & Config") \
|
subject=("[" . $identity . "] Backup & Config") \
|
||||||
body=("Backup and config export for " . $identity . ".\n\n" . \
|
body=("Backup and config export for " . $identity . ".\n\n" . \
|
||||||
|
@ -48,6 +69,7 @@
|
||||||
"Channel: " . $channel . "\n" . \
|
"Channel: " . $channel . "\n" . \
|
||||||
"RouterOS: " . $installedversion . "\n\n" . \
|
"RouterOS: " . $installedversion . "\n\n" . \
|
||||||
"Backup attached: " . $"backup-send-binary" . "\n" . \
|
"Backup attached: " . $"backup-send-binary" . "\n" . \
|
||||||
"Config attached: " . $"backup-send-export") \
|
"Config attached: " . $"backup-send-export" . "\n" . \
|
||||||
|
"Cloud backup: " . $cloudstatus) \
|
||||||
file=$attach;
|
file=$attach;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
# This defines what backups to generate and what password to use.
|
# This defines what backups to generate and what password to use.
|
||||||
:global "backup-send-binary" false;
|
:global "backup-send-binary" false;
|
||||||
:global "backup-send-export" true;
|
:global "backup-send-export" true;
|
||||||
|
:global "backup-cloud" false;
|
||||||
:global "backup-password" "v3ry-s3cr3t";
|
:global "backup-password" "v3ry-s3cr3t";
|
||||||
|
|
||||||
# Specify an address to enable auto update to version assumed safe.
|
# Specify an address to enable auto update to version assumed safe.
|
||||||
|
|
Loading…
Reference in a new issue