MikroTik backup email

Новый скрипт для оправки бэкапов конфигурации с MikroTik RouterOS 7 отличается от RouterOS 6, который работает по другому.

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

Telegram: @Engineer_MikroTik

Навигация

RouterOS 7

{
#Email account settings
:local smtpserv [:resolve "smtp.сервер"];
:local EaccountFrom "отправитель";
:local EaccountTo "получатель";
:local pass "пароль";

#Getting information about the system and deleting old backups
:log info "Starting Backup Script...";
:local sysname [/system/identity/get name];
:local sysver [system/package/get routeros 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...";
/tool e-mail send from=$EaccountFrom to=$EaccountTo server=$smtpserv port=587 user=$EaccountFrom password=$pass tls=starttls file=$backupfile subject=("$sysname Full Backup (" . [/system clock get date] . ")") body=("$sysname full Backup file see in attachment. RouterOS $sysver");
:delay 5;

#Create and E-mail Config 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=$EaccountTo server=$smtpserv port=587 user=$EaccountFrom password=$pass tls=starttls file=$exportfile subject=("$sysname Config Script Backup (" . [/system clock get date] . ")") body=("$sysname Config Script file see in attachment. RouterOS $sysver");
:delay 5;

#Finish
:log info "All System Backups successfully sent. Backup is complete.";
}

RouterOS 6

Top