📧 Email Backup
Automatically export your MikroTik router configuration and send it via email. This is essential for disaster recovery and maintaining offsite backups of your network setup. This guide shows you how to configure SMTP settings and create a scheduled backup script that emails your configuration file daily.
Prerequisites
- ✅ MikroTik RouterOS device with email service enabled
- ✅ Gmail account (or SMTP server credentials)
- ✅ Router has internet connectivity
- ✅ System time is set correctly (for date-stamped backups)
- ✅ Access to RouterOS console (SSH, WebFig, or WinBox)
This guide uses Gmail SMTP. If using a different email provider, adjust the SMTP settings accordingly.
Configuration Steps
Option A: Terminal Configuration
-
Access the terminal via SSH, console, or WebFig terminal
ssh admin@your-router-ip -
Configure SMTP settings for Gmail:
/tool e-mail
set address=smtp.gmail.com \
from="your-email@gmail.com" \
password="your-app-password" \
port=587 \
start-tls=yes \
user="your-email@gmail.com"warningFor Gmail: Use an App Password, not your regular Gmail password.
- Enable 2-Factor Authentication first
- Generate an app-specific password
- Use that 16-character password in the
passwordfield
-
Create the backup script:
/system script add name="email-backup" source={
:local email "your-backup-email@example.com"
/file remove [find name=export.rsc]
/export file=export
/tool e-mail send to=$email \
subject="$[/system identity get name] $[/system clock get date] export" \
body="Configuration backup - $[/system clock get date]" \
file=export.rsc
} -
Schedule the backup (daily at 2 AM):
/system scheduler add name="daily-backup" on-event="email-backup" start-time=02:00:00 interval=1d
Option B: WebFig Configuration
-
Navigate to Tools > E-mail:
- Address:
smtp.gmail.com - Port:
587 - From:
your-email@gmail.com - User:
your-email@gmail.com - Password:
your-app-password - Start TLS: ✓ (enabled)
- Click Apply
- Address:
-
Add the script via System > Scripts:
- Name:
email-backup - Paste the script from Option A step 3
- Click Apply
- Name:
-
Schedule the job via System > Scheduler:
- Name:
daily-backup - On Event:
email-backup - Start Time:
02:00:00 - Interval:
1d - Click Apply
- Name:
Verification
-
Test the email configuration:
/tool e-mail send to="your-backup-email@example.com" subject="Test from Router" body="Email service is working"Check your inbox within 1-2 minutes.
-
Run the backup script manually:
/system script run email-backupVerify you receive the export file via email.
-
Check the export file exists:
/file printYou should see
export.rscin the file list. -
Verify scheduler is active:
/system scheduler printConfirm
daily-backupis listed and enabled.
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| "Email not sent" error | SMTP credentials incorrect | Verify Gmail app password is correct; check if 2FA is enabled |
| "Connection timeout" | SMTP port blocked | Ensure port 587 is open; try port 25 or 465 |
| "TLS negotiation failed" | Start TLS setting mismatch | Confirm start-tls=yes is set; try start-tls=no if using port 465 |
| Email arrives late/never | Scheduler not running | Check /system scheduler print; verify system clock is accurate |
| "Permission denied" on file removal | Export file locked | Wait a few seconds; try script again |
| Wrong identity name in subject | System identity not set | Set identity: /system identity set name="MyRouter" |
Completion
✅ Your router now backs up automatically!
Next steps:
- Test the scheduler by checking your email tomorrow at the scheduled time
- Add additional recipients to the script (comma-separated in
tofield) - Consider rotating old exports to conserve storage:
if ($[/file get [find name=export.rsc] size] > 5M) then { /file remove [find name=export.rsc] } - Back up the export file locally to a secure location