Mikrotik AutoBackup : Send Backup File to FTP Server Automatically

Mikrotik AutoBackup : Send Backup File to FTP Server Automatically

Doing Mikrotik configuration backups regularly can reduce the risk of long downtime because you have to reconfigure the router when a problem occurs on the router. At least if the router is damaged, or the RouterOS is corrupt, we don’t have to bother configuring it from the start. Just restore the configuration from the previously saved backup file.

But the problem is that sometimes we are too lazy to just backup the configuration and save it. Just as lazy as me who has to manage dozens of Mikrotik Routers. Tired of having to backup configs one by one.

Actually there are several other Autobackup ways on Mikrotik such as:

  1. Auto Backup Mikrotik Configuration with Script and Scheduler
  2. Send Automatic Mikrotik Backup via Email

This Mikrotik tutorial is a development of the tutorial, where the backup and export files that have been generated are not sent to email, but are uploaded to a folder on the FTP Server automatically and on a scheduled basis. So that the backup & export files uploaded to FTP will be neatly organized, easy to find, and fast to use. An example is like this:

Let’s just talk about how. Here we will use the Mikrotik Fetch Tool to perform the file upload process. Besides that, we will also use Script & Scheduler for its automation.

How to AutoBackup Mikrotik: Send Backup Files to FTP Server Automatically

  • Make sure we have access to the FTP Server to create a directory where to upload backup files.
  • Login via Winbox Mikrotik –> Make sure the Mikrotik is able to ping the FTP Server.
  • Create a Mikrotik Auto Backup Script. Go to the System menu –> Scripts –> Add a new script –> Name autobackup –> in the Source column, fill in:

/system backup save name=(“BACKUP” . “-” . [/system identity get name] . “-” . \
[:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 7 11]);
/export file=(“BACKUP” . “-” . [/system identity get name] . “-” . \
[:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 7 11]);

An example is like the following image:

Intsall Foam Inside The Keyboards C...
Intsall Foam Inside The Keyboards Case

This script when run will generate backup files (.backup) and export files (.rsc) with easily recognizable naming formats.

  • Create a script again for the backup file upload process. Here we will create two separate scripts for uploading .backup and .rsc files. For the backup file upload script, name it uploadbackup –> The script source is as follows:

:global backupname (“BACKUP” . “-” . [/system identity get name] . “-” . \
[:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 7 11] . “.backup”);
/tool fetch address=Alamat.FTP mode=ftp user=Username.FTP password=Password.FTP src-path=$backupname dst-path=”Direktori.FTP/$backupname” upload=yes

Please change the data marked in yellow with your own data. An example is as follows:

This script was created for the export file upload process (.rsc) –> Name it uploadrsc –> Fill in the Source with the following script:

:global backupname (“BACKUP” . “-” . [/system identity get name] . “-” . \
[:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 7 11] . “.rsc”);
/tool fetch address=Alamat.FTP mode=ftp user=Username.FTP password=Password.FTP src-path=$backupname dst-path=”Direktori.FTP/$backupname” upload=yes

An example is like the following image:

  • Next we try to run the two upload scripts. Try checking the upload destination folder on the FTP Server. If the script configuration is correct, the .backup and .rsc files should appear as shown below:

If the backup file doesn’t appear, please check the data in the script again. Make sure the FTP username and password have Permission Read/Write (RW) access rights in the upload destination folder.

  • Now it’s time to make a schedule, so that the script can be run automatically and scheduled. We use the Scheduler, go to the System menu –> Scheduler –> create 3 new schedulers for each script that we have created.

Here I give an example to make the script run automatically on March 1, 2017 with 30 day intervals, so this script will run from March 1, 2017 and will run automatically every 30 days.

Make sure the three scripts are not executed automatically at the same time. First the autobackup script, then uploadbackup and uploadrsc scripts. An example of its configuration please see the following image:

Well, now it’s just another Mikrotik Router config to auto backup to the FTP Server too. It doesn’t matter if you are tired of configuring at the beginning, as long as you don’t get tired every month collecting backup files one by one.