mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-21 11:24:31 +02:00
email-backup: send backup and config export in one mail
This commit is contained in:
parent
587fef5451
commit
dee4495c0c
1 changed files with 23 additions and 20 deletions
43
email-backup
43
email-backup
|
@ -12,8 +12,13 @@
|
||||||
:global "backup-send-export";
|
:global "backup-send-export";
|
||||||
:global "backup-password";
|
:global "backup-password";
|
||||||
|
|
||||||
|
:if ($"backup-send-binary" = false && $"backup-send-export" = false) do={
|
||||||
|
: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 attach [ :toarray "" ];
|
||||||
|
|
||||||
# get some system information
|
# get some system information
|
||||||
:local model [ / system routerboard get model ];
|
:local model [ / system routerboard get model ];
|
||||||
|
@ -21,32 +26,30 @@
|
||||||
: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 and email binary backup
|
# create binary backup
|
||||||
:if ($"backup-send-binary" = true) do={
|
:if ($"backup-send-binary" = true) do={
|
||||||
/ system backup save name=$filename password=$"backup-password";
|
/ system backup save name=$filename password=$"backup-password";
|
||||||
/ delay delay-time=10;
|
/ delay delay-time=10;
|
||||||
/ tool e-mail send to=$"email-backup-to" cc=$"email-backup-cc" \
|
:set attach ( $attach, ($filename . ".backup") );
|
||||||
subject=("[" . $identity . "] Backup") \
|
|
||||||
body=("Backup file for " . $identity . " is attached.\n\n" . \
|
|
||||||
"Routerboard: " . $model . "\n" . \
|
|
||||||
"Serial number: " . $serialnumber . "\n" . \
|
|
||||||
"Hostname: " . $identity . "\n" . \
|
|
||||||
"Channel: " . $channel . "\n" . \
|
|
||||||
"RouterOS: " . $installedversion) \
|
|
||||||
file=($filename . ".backup");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# create and email 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;
|
||||||
/ delay delay-time=10;
|
/ delay delay-time=10;
|
||||||
/ tool e-mail send to=$"email-backup-to" cc=$"email-backup-cc" \
|
:set attach ( $attach, ($filename . ".rsc") );
|
||||||
subject=("[" . $identity . "] Config") \
|
}
|
||||||
body=("Config file for " . $identity . " is attached.\n\n" . \
|
|
||||||
"Routerboard: " . $model . "\n" . \
|
# email files
|
||||||
"Serial number: " . $serialnumber . "\n" . \
|
/ tool e-mail send to=$"email-backup-to" cc=$"email-backup-cc" \
|
||||||
"Hostname: " . $identity . "\n" . \
|
subject=("[" . $identity . "] Backup & Config") \
|
||||||
"Channel: " . $channel . "\n" . \
|
body=("Backup and config export for " . $identity . ".\n\n" . \
|
||||||
"RouterOS: " . $installedversion) \
|
"Routerboard: " . $model . "\n" . \
|
||||||
file=($filename . ".rsc");
|
"Serial number: " . $serialnumber . "\n" . \
|
||||||
|
"Hostname: " . $identity . "\n" . \
|
||||||
|
"Channel: " . $channel . "\n" . \
|
||||||
|
"RouterOS: " . $installedversion . "\n\n" . \
|
||||||
|
"Backup attached: " . $"backup-send-binary" . "\n" . \
|
||||||
|
"Config attached: " . $"backup-send-export") \
|
||||||
|
file=$attach;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue