Backup database userman secara otomatis kirim ke email


Cara backup database userman tersebut bisa dilakuakan secara periodik dan dikirim secara otomatis ke alamat email kita, jadi tidak perlu lagi tiap hari melakukan backup database userman kemudian mendownloadnya ke komputer.

Langsung sajah…
Masuk ke winbox kesayangan anda, klik System -> Script
Klik tanda + kemudian beri nama : userman, pada kolom source masukan kode berikut :

#----deklarasi variable-----------------------
#:local ts [/system clock get time]
#:set ts ([:pick $ts 0 0].[:pick $ts 3 5].[:pick $ts 6 8])
:local ds [/system clock get date]
:set ds ([:pick $ds 7 11].[:pick $ds 0 3].[:pick $ds 4 6])
:local identitasRouter [/system identity get name];
:local emailTujuan [/tool e-mail get from];
:local seriMikrotik [/system resource get board-name];
#--------------------------------------
#-----Backup usermanager mikrotik---------------
:local usermanBackup ($identitasRouter.$seriMikrotik."-userman-".$ds.".umb")
/tool user-manager database save name=$usermanBackup;
#-----Mengirim email-------------------
:delay 10s
:log info "Sedang mengirim email, silahkan tunggu beberapa detik..."
/tool e-mail send subject=$usermanBackup body=$usermanBackup to=$emailTujuan tls=yes file=$usermanBackup
:log info "Email sudah terkirim..."
#--------------------------------------
#-----menghapus -----------------------
:delay 60s
:if ([:len [/file find name=$usermanBackup]] > 0) do={/file remove $usermanBackup}
:log info "File $usermanBackup telah dihapus..!"

Klik OK

Kemudian kita buat scheduler yang bertugas untuk mengeksekusi script yang telah kita masukan tadi.

Klik System -> Scheduler, klik tanda + kemudian masukan nama : userman, interval : 1d 00:00:00 dan pada kolom on event isi dengan userman.

klik OK

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s