Backup mikrotik configuration ke email gmail

Untuk melakukan backup mikrotik, silahkan gunakan script backup yang dapat di running setiap hari. Di sini kami akan memberikan penjelasan bagaimana cara melakukan backup configuration mikrotik secara berkala kedalam email gmail kalian.

  1. kita memanfaatkan SMTP gmail untuk mengirim email ke diri sendiri.
  2. buka system -> script -> tambahkan script baru dengan nama “backup”

Policy di centang semuanya, isikan script source sebagai berikut:

#### Modify these values to match your requirements ####

#Your email address to receive the backups
:local toemail "xxx@gmail.com"

#The From address (you can use your own address if you want)
:local fromemail "xxx@gmail.com"

#A mail server your machines can send through
:local emailserver "74.125.200.108"

:local password "xxx"

############## Don’t edit below this line ##############


:local sysname [/system identity get name]
:local textfilename
:local backupfilename
:local time [/system clock get time]
:local date [/system clock get date]
:local newdate "";
:for i from=0 to=([:len $date]-1) do={ :local tmp [:pick $date $i];
:if ($tmp !="/") do={ :set newdate "$newdate$tmp" }
:if ($tmp ="/") do={}
}
#check for spaces in system identity to replace with underscores
:if ([:find $sysname " "] !=0) do={
:local name $sysname;
:local newname "";
:for i from=0 to=([:len $name]-1) do={ :local tmp [:pick $name $i];
:if ($tmp !=" ") do={ :set newname "$newname$tmp" }
:if ($tmp =" ") do={ :set newname "$newname_" }
}
:set sysname $newname;
}
:set textfilename ($"newdate" . "-" . $"sysname" . ".rsc")
:set backupfilename ($"newdate" . "-" . $"sysname" . ".backup")
:execute [/export file=$"textfilename"]
:execute [/system backup save name=$"backupfilename"]
#Allow time for export to complete
:delay 2s


#email copies
:log info "Emailing backups"
/tool e-mail send to=$"toemail" from=$"fromemail" start-tls=yes port=587 subject="[Mikrotik Backup Export] $sysname $time" file=$"textfilename" user=$"fromemail" password=$"password"
#Send as different subjects to force GMail to treat as new message thread.
:local time [/system clock get time]
/tool e-mail send to=$"toemail" from=$"fromemail" start-tls=yes port=587 subject="[Mikrotik Backup] $sysname $time" file=$"backupfilename" user=$"fromemail" password=$"password"

#Allow time to send
:delay 10s

#delete copies
/file remove $textfilename
/file remove $backupfilename

pastikan warna merah2 diganti dengan account gmail anda.

3. buka system -> scheduler -> buat schedule baru dengan nama “backup” start date isikan tanggal hari ini, start time isikan jam berapa script mau di eksekusi, interval isikan 1d 00:00:00 yang artinya setiap 1 hari script akan dipanggil.
on event: backup
policy: centang semuanya
klik save/ok.

4. buka tools -> email dan isikan dan simpan sbb:
server: 74.125.200.108
port: 587
start TLS: yes
from: < >
user: alamatemail@gmail.com
pass: xxxx

5. silahkan tunggu dan pastikan scheduler ada jalan dengan benar dengan melihat kolom “run count” yang artinya sudah berapa kali scheduler tsb di running. Sekian tutorial singkat dari kami semoga bermanfaat.

Salam,

Rian Dknet

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *