Automatic MikroTik Backup by Email Every Day
Make your MikroTik router back itself up every night and email the files to you, with a script and scheduler, including Gmail settings and tips for keeping backups safe.
Problem
Backups are only useful if they are recent. Taking them by hand is easy to forget, so you want the router to send you a backup every day automatically.
Symptoms
- The latest backup you can find is months old.
- A router failed and you had to rebuild it from memory.
Likely causes
No scheduled backup, or backups stored only on the router itself (they are lost with the router).
Prerequisites
- An email account for sending. For Gmail, turn on 2-step verification and create an App Password.
- Correct time on the router (NTP), so file dates make sense.
Solution (WinBox / CLI)
1. Email settings (RouterOS v7.12 and later. Older v7 versions use address= instead of server=; RouterOS v6 uses address= and start-tls=yes):
/tool e-mail set server=smtp.gmail.com port=587 tls=starttls user=yourname@gmail.com password=YOUR_APP_PASSWORD from=yourname@gmail.com2. Backup script. It saves a password-protected binary backup and a text export, then emails both:
/system script add name=auto-backup policy=read,write,policy,test,sensitive source={
/system backup save name=auto-backup password=BackupPassword123
/export file=auto-export
:delay 5s
/tool e-mail send to="yourname@gmail.com" subject=("Backup " . [/system identity get name]) body="Daily backup attached" file=auto-backup.backup
:delay 10s
/tool e-mail send to="yourname@gmail.com" subject=("Export " . [/system identity get name]) body="Daily export attached" file=auto-export.rsc
}3. Run it every night at 2 AM:
/system scheduler add name=daily-backup interval=1d start-time=02:00:00 on-event=auto-backup policy=read,write,policy,test,sensitiveNote: On RouterOS v7, /export hides passwords by default. Keep it that way for emailed files; the binary backup (protected with a password) contains everything.
Verification
Run the script once by hand and check your inbox:
/system script run auto-backup
/log print where topics~"e-mail"Common errors
- Gmail rejects the login: use an App Password, not your normal password.
tlssetting wrong: port 587 needsstarttls, port 465 needsyes.- The email arrives without an attachment: increase the
:delayso the file is finished before sending.
Rollback
/system scheduler disable daily-backupWatch the video (Bangla): Automatic MikroTik router backup by email
This topic is covered hands-on in MTCNA — MikroTik Certified Network Associate.
View MTCNA