Backup-cronjob for Mikrotik RouterOS configuration

To periodically backup the configuration of our new routers with Mikrotik RouterOS, I wanted to have a cronjob: get an export of the active configuration, perhaps even a system backup, store in a backup folder and keep them for a defined retention period.

So I ended up writing the cronjob myself, which resulted in a small bash script.

Backup_RouterOS uses and requires SSH access to the target router, as well as SFTP. There is no additional scheduling or scripting on the device itself, the cronjob works completely from remote. To improve things, the bash script is able to handle more than one router, storing the backups in folders for each router and each day.

To set up the backup script, please feel free to copy it:

As always, this cronjob comes without any warranty. Please test and do not use in production before that!