Featured image of post Mikrotik: Save your config via FTP

Mikrotik: Save your config via FTP

Make your mikrotik great again... save your config securely

Do you have a MikroTik? Have you ever made changes to the configuration and then, after a while, when you reset the configuration, it didn’t work as you expected?

Don’t worry, if you have an FTP server at home, we can solve this quickly and easily.

I’m going to tell you a very simple way (really, a very simple way) to make FTP backups of your MikroTik and keep your configurations safe.

Download the script from our repository: ftp_backup

Configure the script

Create the script in System -> Scripts menu, click on Add new, and fill in the form fields as follows:

- Name: ftp_backup
- Policy: read, write, test

In the script, variables are defined through the :local refs where you need to put the information:

:local FTPserver "x.x.x.x"
:local FTPuser "username"
:local FTPpassword "password"
:local FTPdestFile "remote_directory"

Just fill the spaces between double commas for each variable with the values you got in the previous step.

Now, you can test the script by applying and clicking on Run Script, or via cli:

/system scripts run ftp_backup

Scheduling the script

Now here’s the thing. We got everything set up, verified that runs as intended, and everything is ready. But at this point, if you don’t click on the “Run script” button, the script won’t trigger itself. Hopefully that is quite simple to fix: just configure a Scheduler to run this script on a given time basis (say 1d).

To achive this, from your Mikrotik’s web UI, go to System -> Scheduler menu, and click on Add new, then just fill each field with the next details:

- Name: ftp_backup
- Interval: 1d
- Start time: 23:00:00
- Policy: read, write, test
- On event: /system script run ftp_backup

If you prefer setting this up through the cli, this is done just by running the following command:

/system scheduler
add interval=1d name=ftp_backup on-event="/system script run ftp_backup" policy=read,write,test start-time=23:00:00

Remember that you can change the interval accordingly to fit your own needs.

With that, we can say we’re done! You have configured the FTP backup on your Mikrotik, and now you can break anything in your config, you have a backup!

See you next time, don’t forget to share & leave a comment!

Built with Hugo