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=220.127.116.11 \ secondary-ntp=18.104.22.168 # 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. # email@example.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 firstname.lastname@example.org \ subject=([/system identity get name] . " \ Backup") email@example.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.