Using the built in Mikrotik scripting and email tools is an easy way to create automatic backups, that are emailed to you everyday at scheduled times. This guide will give you a detailed walk through of the 3 parts to setting this up.
Part 1 – Backup Script:
Connect to your router via Winbox. Once there, navigate to System > Scripts and click on the + button to add a new sctipt.

In the “New Script” window, name your script “daily-backup”. The default settings that have all the permissions ticked is fine. Having “Don’t Require Permission” unticked is fine.

Inside the “Source” is where you write the actual script that runs.
I have a simple template setup below that you can use, and customize:
:log info "Starting daily backup";
#File names:
/system backup save name=my-backup
/system package print file=router-packages.txt
#include show-sensitive in export if you need keys, passwords etc... V7 only.
/export show-sensitive file=my-export.rsc
:log info "Backup and rsc generated, sending via email in 10 seconds";
:delay 00:00:10;
#Details for email - Replace mail@example.com with a real address:
tool e-mail/send file=my-export.rsc,my-backup.backup,router-packages.txt to=mail@example.com subject="Router backup $[/system clock get date] at $[/system clock get time]" body="Routers daily backup files."
:log info "Daily backup script completed";
#End of Script - thesebytes.net
Notes:
- I’ve highlighted the important parts of this script in red. If you change the file names, do not not use any spaces, and ensure that you’re using the correct file names when adding them the “file=” section of the email.
- Add a real email address in the “to=” section of the script.
- Lines that start with a “#” are comments, and are not run as functions or commands. All comments must be on their own line.
- Modify the export perimeters as needed, such as verbose, etc. The default export behavior is compact, which is fine in most cases and what this script runs. Read more here: Configuration Export
- Your email might fail to send if your outgoing public IP address is on a blacklist.
What the script does in sequential order:
- When “:log info” is used, the script prints the string inside the quotation marks to the sys log. This is great, because you can open your sys log and see the script executing in real time.
- The Mikrotik then generates a backup file, a package info file and a config export file and saves them to its local storage.
- A 10 second delay is placed after file generation to give the router time to finalize the files before the rest of the script runs. This isn’t strictly necessary, however a delay after generating files can act as a fail-safe in some cases especially on overloaded devices.
- “tool e-mail” is then used to generate an email that contains all three files as attachments, a time stamped subject, and a descriptive body – mail@example.com is the recipient, and must be replaced with the email address where you’d like the backups to be sent. The time and date on your router should be set correctly! See my post on how to do this using NTP here: MikroTik V7 NTP Client Setup: Connect and Sync to Global Time Servers

Hit apply and OK. Once done you should see that script appear in your script list:

With the script correctly setup and created, we can now move onto the next part of this walk through.
Part 2 – Email Setup:
In order for the Mikrotik to email a script, it needs its email client to be configured. Luckily this is pretty simple, and only requires a valid email account, and SMTP server details.
In Winbox, navigate to Tools > Email to open the email client settings:

Here I’ve setup a temp email account on my email server for TheseBytes, however you can use any valid email server and email account, even Gmail – Mikrotik Email Wiki.
Email Settings:
Server: Your mail server address
Port: Your mail servers listen port
TLS: TLS settings that match your server (I strongly advise using encryption when sending these files via email)
VRF: What VRF to use when sending email out (most cases keep this on main)
From: The name or email you want to show the receiver
User: The username for the email account
Password: Your email account password
After adding in valid email credentials, hit “OK” to save these settings. With that done, your Mikrotik should be able to send emails, provided it has internet access and DNS.
You should now be able to run your script to test its functionality. Navigate back to the Script List window, click on your script and then press “Run Script” – You should see the run count go up, and the sys log display the correct logging info and script execution. If you have any errors, the sys log should be able to tell you what line is broken and what the bug relates to.

Here’s what it looks like on my email client:

As you can see, the subject is there, with the time and date pulled from the router, the 3 files the script generated as attachments, and the descriptive body.
With all of this done, all that’s left to do is automate the script execution.
Part 3 – Scheduled Automation:
The third and final step is what enables the automation part of this whole thing. By utilizing the built in “Scheduler” tool in RouterOS, we can effectively create a time based rule that runs our backup script at specific times every day.
Inside Winbox, navigate to System > Scheduler and click on the + button to add a new schedule:

In the “New Schedule” window, add the following details:
Name: daily backup
Start Date: Leave default, router should auto fill with correct date, else put in todays date
Start Time: 00:00:00
Interval: 1d 00:00:000
On Event: daily-backup (this must be the exact name of your scrip)
Leave everything else as default, and click apply:

You will now see your daily backup schedule, and an updated “Next Run” time – this is the next time that this schedule will run the script.

#End of post