Отправка backup MikroTik на email

Простой скрипт, который я сам использую для отправки бэкапов на почту. Рекомендую запускать вручную до после каждой правки.

Профессиональная настройка MikroTik
Без предоплаты

Telegram: @Engineer_MikroTik

Подставляете свои значения EaccountFrom от кого, EaccountTo1 и EaccountTo2 кому

Для RouterOS 7 скрипт отличается

В /system script добавляем скрипт backup

{
#Create Variables
:local smtpserv [:resolve "smtp.yandex.ru"];
:local EaccountFrom "mikrotik@yandex.ru";
:local EaccountTo1 "email1.D@JfhygkfjHuikhfnsd.ru";
:local EaccountTo2 "email2.D@JfhygkfjHuikhfnsd.ru";
:local pass "hgiyiuhK6tlh";

#
:log info "Starting Backup Script...";
:local sysname [/system identity get name];
:local sysver [/system package get system version];
:log info "Flushing DNS cache...";
/ip dns cache flush;
:delay 2;
:log info "Deleting last Backups...";
:foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] "$sysname-backup-"]]!="nil") do={/file remove $i}};
:delay 2;

#Create and E-mail Full Backup
:local backupfile ("$sysname-backup-" . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".backup");
:log info "Creating new Full Backup file...";
/system backup save name=$backupfile;
:delay 2;
:log info "Sending Full Backup file via E-mail 1...";
/tool e-mail send from=$EaccountFrom to=$EaccountTo1 server=$smtpserv port=587 user=$EaccountFrom password=$pass start-tls=yes \
      file=$backupfile subject=("$sysname Full Backup (" . [/system clock get date] . ")") \
      body=("$sysname full Backup file see in attachment. \nRouterOS version: $sysver.");
:delay 5;

:log info "Sending Full Backup file via E-mail 2...";
/tool e-mail send from=$EaccountFrom to=$EaccountTo2 server=$smtpserv port=587 user=$EaccountFrom password=$pass start-tls=yes \
      file=$backupfile subject=("$sysname Full Backup (" . [/system clock get date] . ")") \
      body=("$sysname full Backup file see in attachment. \nRouterOS version: $sysver.");
:delay 5;

#Create and E-mail Setup Backup
:local exportfile ("$sysname-backup-" . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc");
:log info "Creating new Setup Script file...";
/export file=$exportfile;
:delay 2;
:log info "Sending Setup Script file via E-mail...";
/tool e-mail send from=$EaccountFrom to=$EaccountTo1 server=$smtpserv port=587 user=$EaccountFrom password=$pass start-tls=yes \
      file=$exportfile subject=("$sysname Setup Script Backup (" . [/system clock get date] . ")") \
      body=("$sysname Setup Script file see in attachment. \nRouterOS version: $sysver.");
:delay 5;

:log info "Sending Setup Script file via E-mail...";
/tool e-mail send from=$EaccountFrom to=$EaccountTo2 server=$smtpserv port=587 user=$EaccountFrom password=$pass start-tls=yes \
      file=$exportfile subject=("$sysname Setup Script Backup (" . [/system clock get date] . ")") \
      body=("$sysname Setup Script file see in attachment. \nRouterOS version: $sysver.");
:delay 5;

#Finish
:log info "All System Backups emailed successfully.\nBackuping completed.";
}

Можно настроить бэкап на почту раз в N времени:

Добавить в System Sheduler:

/system script run Backup

Более продвинутый вариант с проверкой изменений:

Обсудить статью на Dzen

Top