Mikrotik - Auto Backup Script


Kita mau backup otomatis router mikrotik kita berikut konfig nya

System -> Script

System -> Schedular

Contoh Config

/system scheduler
add comment="Backup Ostomastis" interval=1d name=AutoBackup on-event=backup \
    policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
    start-date=feb/25/2016 start-time=01:00:00

/system script
add name=backup owner=admincni policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive source="\
    \n:global time [/system clock get time];\
    \n:global date [/system clock get date];\
    \n:global datetimestring ([:pick \$date 4 6] .\"-\". [:pick \$date 0 3] .\
    \"-\". [:pick \$date 7 11]);\
    \n:global routername [/system identity get name];\
    \n \
    \n:global server \"\";\
    \n:global user \"nazar@cni.net.id\";\
    \n:global pass \"pass_nazar\";\
    \n:global from \"backup@cni.net.id\";\
    \n:global to \"backup@cni.net.id\";\
    \n:global subject \"Backup \$routername \$date\";\
    \n:global body \"Backup file di generate pada \$date \$time WIB\";\
    \n:global file \"\$routername_\$datetimestring.backup\";\
    \n \
    \n:log info \"Backup JOB Started...\";\
    \n/system backup save name=\"\$routername_\$datetimestring\";\
    \n \
    \n:delay 10s;\
    \n:log info \"Start Sending Backup File to NOC...\";\
    \n \
    \n/tool e-mail send to=\$to user=\$user password=\$pass from=\$from server\
    =\$server body=\$body subject=\$subject file=\$file;\
    \n \
    \n:delay 40s;\
    \n:log info \"Backup JOB Finished\";\
    \n/file remove \"\$routername_\$datetimestring\"; "

Script Asli:

:global time [/system clock get time];
:global date [/system clock get date];
:global datetimestring ([:pick $date 4 6] ."-". [:pick $date 0 3] ."-". [:pick $date 7 11]);
:global routername [/system identity get name];

:global server "mail.cni.net.id";
:global user "nazar@cni.net.id";
:global pass "password_nazar";
:global from "backup@cni.net.id";
:global to "backup@cni.net.id";
:global subject "Backup $routername $date";
:global body "Backup file di generate pada $date $time WIB";
:global file "$routername_$datetimestring.backup";

:log info "Backup JOB Started...";
/system backup save name="$routername_$datetimestring";

:delay 10s;
:log info "Start Sending Backup File to NOC...";

/tool e-mail send to=$to user=$user password=$pass from=$from server=$server body=$body subject=$subject file=$file;

:delay 40s;
:log info "Backup JOB Finished";
/file remove "$routername_$datetimestring";

Note: Tambahan untuk dibaca-baca: Ref: https://www.youtube.com/watch?v=uYFssLbAbSI

Related Posts:

0 Response to "Mikrotik - Auto Backup Script"

Posting Komentar