Home > MikroTik Router > MikroTik Router Auto Backup via Email

MikroTik Router Auto Backup via Email

MikroTik Router by default provides a lot of tools for reducing system admin’s burden. E-mail tool is one of them. Using this tool system administrator can automate configuration file backup regularly via email and can reduce his/her daily manual task easily. So, this article is designed to show how to configure MikroTik Router Auto Backup via Email with a few steps.

MikroTik Router basic configuration was explained in my previous article. If you are new here, feel free to spend some time to study about MikroTik Router basic configuration and then continue the rest of this article.

MikroTik Router Automated Email Backup Steps:

  1. Email configuration
  2. Writing script for storing backup and sending Email
  3. Creating scheduler for running script regularly

MikroTik Router Email Configuration

For sending email from router, first you need to configure sender email. For this do the below steps:

  1. Go to Tools > Email and provide sender email information as below:
    Server: SMTP Server IP address (Use your mail server IP or try using this Gmail IP: 173.194.77.108)
    Port: SMTP Server Port (usually 25 or if you use Gmail SMTP, use 587)
    From: Put your email address here that will indicate from address.
    User: Put email user name (first part of @ sign) or full email address if applicable.
    Password: Put your email password.
  2. Alternatively, you can do below cmd:/tool e-mail
    set address=173.194.77.108
    set port=587
    set from=systemzonedotnet@gmail.com
    set user= systemzonedotnet
    set password=*******
    Where 173.194.77.108 is Gmail SMTP Server IP, systemzonedotnet@gmail.com is a test mail ID created for this article and “*******” is the password.
  3. For checking email configuration, send a test mail from MikroTik with below cmd:/tool e-mail send to=sezan.sayeed@yahoo.com subject=”email test” body=”email test” tls=yes

If everything is OK, the test email will be sent to the receiver email address. Email configuration is now complete. Next we shall write script for storing backup file and sending via mail.

Script for storing backup file and sending via email

Now we shall write a script that will store backup file and then send the backup file to the desired mail address. Follow below steps to do that.

  1. Go to System > Scripts and click add (+) new button.
  2. Type your script name (for example, Mail Backup) at Name field and then copy and paste the below code in source box.
    :log info “Mikrotik Backup JOB Started . . . “
    :global backupfile configbackup
    :log info “Deleting old Backup File If available otherwise ignore & process further . . . “
    /system backup save name=$backupfile
    :log info “Backup process pausing for 10s so it complete creating backup file”
    :delay 10s
    :log info “Start Sending Backup File via Email using GMAIL SMTP  . . .” tool e-mailsend to=sezan.sayeed@yahoo.com subject=([/system clock get date] . \ ” MikroTik Backup”) body=”MikroTik email Backup” tls=yes file=$backupfile
    :delay 40s
    :log info “Backup Finished”
    :log info “Deleting Backup File. All Done.”
    /file remove $backupfile
  3. Now click Apply and OK button for saving this script.
  4. You can run this script manually by clicking Run Script button or typing this cmd: > system script run 0 

Our script for storing configuration backup file and sending the file via email is now ready. Next we shall create a scheduler that will run this script regularly.

Scheduler for Running Script Regularly

Now we shall create a scheduler that will run the above script regularly at our desired time. For this do the below steps:

  1. Go to System > Scheduler and click add (+) new button.
  2. Type scheduler name at Name field and put the Start Time when the script will run. For example, if you want to run the script at 5:30 PM, put time as 17:30:00.
  3. Put sending time interval at Interval field. For example, if you want to run the script daily, put the value as 24:00:00.
  4. Now put your script name (here, Mail Backup) in On Event box and then click Apply and OK button.

Scheduler is now ready. If everything is OK, MikroTik Router will send a mail to the desired email address where configuration file should have attached.

You should follow the above steps one by one otherwise your desired result may not come. So, if you face difficulty to do above steps properly, please watch the below video carefully about MikroTik Router Auto Backup via Email. I hope, it will reduce your confusion.

Note: This configuration has been done in MikroTik Router OS version 5.20. If you face any problem in upgraded version, please let me know. I’ll try to solve the problem.

MikroTik Router configuration file backup via email has been discussed in this article. I hope, you are now able to configure your MikroTik Router for sending configuration file backup via email. If you face any problem, feel free to contact with from Contact page. I’ll try my best to stay with you.

mikrotik-router-auto-backup-via-email

ABOUT ME

I, Md. Abu Sayeed, am a system administrator. I like to share knowledge which I am learning from my daily experience. As a system administrator, I like to play with computer networking, Redhat Linux , Windows server, physical server and storage, virtual technology and other system related topics. I hope, my daily experiences which I am sharing in this website will be beneficial for you. This article is also a practical experience of mine. So, if this article is helpful for you, don't forget to give a positive feedback by sharing on your favorite social media or liking our Facebook Page. You can also keep subscribed to our website for getting email notification of new post by providing your name and email address in Subscription Page.   

Leave a Reply

Your email address will not be published. Required fields are marked *