Mikrotik RouterOS Automated Backup

This article is just a script that you can cut and paste (with small changes) to your router. It will set up the necessary stuff to automate backups.  The script is commented well and the parts that you need to customize are highlighted, so that you know what has to be adjusted.  This is based on a script posted on Mikrotik's website, updated to work in 2.9.x and 3.x.
# Set the NTP servers below.

/ system ntp client
set enabled=yes mode=unicast primary-ntp=24.79.76.105 \
secondary-ntp=24.123.66.139

# This will create a text backup of your system and email it to an email
# address of your choice.  The easiest way to insure you get this right
# is to cut/paste this text into notepad, then search and replace the
# following text with appropriate values.
# you@yourdomain.com - replace with your email address
# X.X.X.X - replace with your mailservers IP ADDRESS (not dns name)
#
# VERY IMPORTANT - this script will not run correctly if the system name
# is set with a space in it.  You can fix this by going to SYSTEM->IDENTITY 
# in Winbox.

/ system script
add name="makebackup" source=":log info "Starting Backup Script"\n \
/export file=[/system identity get name]\n \
:delay 20\n  /tool e-mail send to=you@yourdomain.com \
subject=([/system identity get name] . " \
Backup") from=you@yourdomain.com \
file=([/system identity get name] . ".rsc") \
server=X.X.X.X \n:log info "Finished Backup Script"" \
policy=ftp,reboot,read,write,policy,test

# Set the interval here to schedule the above backup script every
# day/week/month (or hour if you want).  Don't mess with the start
# date or start time unless you have a good reason to do so

/ system scheduler
add name="email-backup" on-event=makebackup \
start-date=mar/03/2006 start-time=02:15:00 \
interval=7d comment="Weekly Backups" disabled=no
The above script can be tested in Winbox by clicking: SYSTEM->SCRIPT, then highlight the makebackup entry and click RUN. You will see entries in the log (click LOG to view these) to indicate the script starting and stopping. When it completes, check your email to insure you get the email with the backup attached. I hope this article has been helpful for you.

2 Responses to “Mikrotik RouterOS Automated Backup”

  1. jluthman Says:

    I had to make a few changes for it to work on my 2.9.40 router, so here is my source:

    :log info “starting backup”
    /export file=[/system identity get name]
    :delay 5
    /tool e-mail send to=user@domain.com subject=”inx core backup” \
    from=router@domain.com file=([/system identity get name] . “.rsc”) \
    server=1.3.3.7
    :log info “finished backup”

    As Butch highlighted above, you will need to modify the to= and server= (the from= is a preference thing, but it is advised you make work with your SMTP server).

    PS: Don’t forget to schedule it =)

  2. machine a sous gratuite sans telechargement Says:

    machine a sous gratuite sans telechargement

    Mikrotik RouterOS Automated Backup | Butch Evans Blog

Leave a Reply

You must be logged in to post a comment.