Backup
Daily Backup by E-mail Usermanager — 6
Creates a system backup, a configuration export and (optionally) a User Manager database file every day and e-mails them to you, then deletes the temporary files. The User Manager part is optional.
RouterOS 6
/system script add name=Mail policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source={
# EN: E-mail address that receives the backups | AR: الايميل الذي ستصله النسخ الاحتياطية
:local emailTo "change here";
# EN: true = also back up the User Manager database (needs the User Manager package), false = skip it
# AR: true لعمل نسخة من قاعدة بيانات User Manager (تحتاج الحزمة)، و false لتخطيها
:local includeUM true;
:if ($emailTo = "change here") do={ :error "Set emailTo first" }
:log info "Backup mail: creating files";
# EN: 1) Binary backup and text export | AR: 1) النسخة الثنائية وملف التصدير
/system backup save name=mt_backup;
/export file=mt_export;
# EN: 2) User Manager database (optional) | AR: 2) قاعدة بيانات User Manager (اختياري)
:if ($includeUM) do={ /tool user-manager database save name=mt_um overwrite=yes }
:delay 10s;
# EN: 3) Send each file in its own e-mail (delays give the mail server time) | AR: 3) إرسال كل ملف في رسالة مستقلة (التأخير لإعطاء السيرفر وقتاً)
/tool e-mail send to=$emailTo subject="MikroTik backup (.backup)" file="mt_backup.backup";
:delay 20s;
/tool e-mail send to=$emailTo subject="MikroTik export (.rsc)" file="mt_export.rsc";
:if ($includeUM) do={
:delay 20s;
:local umFile [/file get [:pick [/file find where name~"mt_um"] 0] name];
/tool e-mail send to=$emailTo subject="MikroTik User Manager database" file=$umFile;
}
# EN: 4) Wait for the mails to leave, then delete the temporary files | AR: 4) الانتظار حتى تُرسل الرسائل ثم حذف الملفات المؤقتة
:delay 40s;
/file remove [/file find where name~"^mt_(backup|export|um)"];
:log info "Backup mail: done";
}
# EN: Run it every day at midnight | AR: تشغيله يومياً عند منتصف الليل
/system scheduler add name=Mail-daily interval=1d start-time=00:00:00 on-event=Mail policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon