#MikrotikTips Auto Backup Mikrotik and auto transfer upload to another mikrotik

2
2679
Halaman:

Script Auto Backup Mikrotik and auto transfer upload to another mikrotik. Penting untuk di pakai sebagai admin jaringan

Informasi umum Auto Backup Mikrotik

  • 2 Unit, Mikrotik 5.20 (main and secondary as backup)
  • User manager installed

Flowchart Auto Backup Mikrotik




  1. Generate backup for UserManager temporary.
    2. log info message=UserManagerBackupFinished.
  2. Generate backup for system temporary.
  3. log info message=SystemBackupFinished.
  4. Upload the UserManagerDB Backup to FTP server.
  5. Upload the System Backup to External FTP server.
  6. remove Temporary back file UserManager + system.
  7. log info message=UserMangerBackup-SystemBackup-TempRemoved.
  8. log info message=UserManger-SystemBackup2CentOS-Finished "FTP server"

SCRIPT Auto Backup Mikrotik
#automated System - UM database backup 2 External FTP
#Get time
:local ts [/system clock get time] :set ts ([:pick $ts 0 2].[:pick $ts 3 5].[:pick $ts 6 8])
#Get Date
:local ds [/system clock get date] :set ds ([:pick $ds 7 11].[:pick $ds 0 3].[:pick $ds 4 6])
#This line to generate the file name for user manager backup - file name will be UMDB- ServerName? - Date? - Time?
:local fname ("/UMDB-".[/system identity get name]."-".$ds."-".$ts.".umb")
#This line to generate the file name for System backup - file name will be UMDB- ServerName? - Date? - Time?
:local fname1 ("/UMDB-".[/system identity get name]."-".$ds."-".$ts.".backup")
#all above is workaround to get unique $filename=UserManagerDB  - $filename1=System
/tool user-manager database save name=$fname
:log info message=UserManagerBackupFinished;
/system backup save name=$fname1
:log info message=SystemBackupFinished;
#Upload the UserManagerDB Backup to External FTP - change address to your ftp server + user + pass
/tool fetch address=192.168.252.2 src-path=$fname user=bb password=bb mode=ftp port=21 dst-path=$fname upload=yes
#Upload the System Backup to External FTP - change address to your ftp server + user + pass
/tool fetch address=192.168.252.2 src-path=$fname1 user=bb password=bb mode=ftp  port=21 dst-path=$fname1 upload=yes
#Delay time to finish the upload - increase it if your backup file is big
:delay 60s;
#Find file name start with UMDB- then remove
:foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] "UMDB-"]]!="nil") do={/file remove $i}}
:log info message=UserMangerBackup-SystemBackup-TempRemoved;
:log info message=UserManger-SystemBackup2CentOS-Finished;

Add schedule to run script everyday or whatever you need

Artikel Terkait :  Cara Mudah Membuat Script dan Schedule Mikrotik - part 1

Note :

- Your secondary mikrotik should has ftp user, write access

- Replace address, user, password and port with your secondary mikrotik

Auto Backup Mikrotik. Auto Backup Mikrotik. Auto Backup Mikrotik.

2 COMMENTS

Jangan lupa tinggalkan komentar ya gais

This site uses Akismet to reduce spam. Learn how your comment data is processed.