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
- Generate backup for UserManager temporary.
2. log info message=UserManagerBackupFinished. - Generate backup for system temporary.
- log info message=SystemBackupFinished.
- Upload the UserManagerDB Backup to FTP server.
- Upload the System Backup to External FTP server.
- remove Temporary back file UserManager + system.
- log info message=UserMangerBackup-SystemBackup-TempRemoved.
- 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
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.
Fine way of explaining, and good post to obtain facts regarding my
presentation subject, which i am going to convey in school.