Wednesday, March 1, 2017

AutoBackup Mikrotik: Send File Backup to FTP Server Automatically

AutoBackup Mikrotik: Send File Backup to FTP Server Automatically


Perform configuration backups mikrotik regularly can reduce the risk of downtime longer having to reset the router config when there are problems on the router. At least if the router is broken, or his RouterOS corrupt, we do not have to bother anymore ngonfig from scratch. A live restore its configuration from a backup file that has been previously saved.

But the problem is sometimes we are too lazy to do just backup the configuration and save it. Same look lazily like me who have to manage dozens Router Mikrotik. Tired when I have a backup config one by one, hehe: D.


Tutorial Mikrotik this time is the development of the tutorial, where the backup files and export that has been generated is not sent to the email, but uploaded to a folder on the FTP Server automatically and scheduled. So the backup and export files uploaded to the FTP will be neatly arranged, easy to find, and can quickly be used. Examples like this:


Okay enough already fairytale before sleep, most read the prologue ntar even so sleepy: p let's just discuss how. Here we will take advantage of Tool Fetch Mikrotik to perform file upload process. In addition we will also use the Script & Scheduler for its automation.

How AutoBackup Mikrotik Tutorial: Send File Backup to FTP Server Automatically

1. Make sure that we have access to the FTP server to create the directory location of the backup file upload.

2. Login via Winbox Mikrotik -> Make sure Mikrotik was already able to ping the FTP Server.

3. Create Auto Backup Mikrotik Script. Go to the menu System -> Scripts -> Add New Script -> Name autobackup -> in the Source column fill:
/ System backup save name = ( "BACKUP". "-". [/ System identity get name]. "-". \
[: Pick [/ system clock date get] 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 date get] 4 6]. [: Pick [/ system clock get date] 0 3]. [: Pick [/ system clock get date] 7 11]);
His example as shown below:


This script if run will generate backup file (.backup) and file export (.rsc) with the naming format that is easily recognizable.


4. Create a script again for the backup file upload process. Here we will create two separate script for file upload process .backup and .rsc. To upload a file backup script named uploadbackup -> Script source is as follows:
: Global backupname ( "BACKUP". "-". [/ System identity get name]. "-". \
[: Pick [/ system clock date get] 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 password = Username.FTP src = Password.FTP-path = $ backupname dst-path = "Direktori.FTP / $ backupname" upload = yes
Please change your data is marked yellow with your own data. The example is as follows:


5. This script is created for the export file upload process (.rsc) -> Name uploadrsc -> Fill Source with the following script:

: Global backupname ( "BACKUP". "-". [/ System identity get name]. "-". \
[: Pick [/ system clock date get] 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 password = Username.FTP src = Password.FTP-path = $ backupname dst-path = "Direktori.FTP / $ backupname" upload = yes

His example as shown below:


6. Then we try Run both the upload script. Try to check the upload destination folder on the FTP Server. If the configuration script is correct, should appear .backup and .rsc file as shown below:

If not appear its backup file, please check again the data on his script. Make sure the FTP username and password it has permissions Permission Read / Write (RW) in the destination folder upload.

7. Now it's time mambuat scheduling, so that the script can be run automatically and scheduled. We use the Scheduler, go to the menu System -> Scheduler -> create three new scheduler for each script we've created.

Here I demonstrated to make the script run automatically on March 1, 2017 at 30-day intervals, so this script will run from March 1, 2017 and will run automatically every 30 days.

Make sure that no third script executes automatically at the same time. FIRST autobackup script, then the script uploadbackup and uploadrsc. Its configuration examples please see the following picture:

Well, now more Mikrotik Router config for auto backup to an FTP server as well.

1 comment:

  1. here is another script for automatic update and backup to an email
    https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update

    ReplyDelete