前言
打開 System/Scripts,新增一個新的Script並命名為"gmail_backup_system"
將Script貼入Source內
#Script Name:gmail_backup_system
#本Script為參考"電腦茶包 Blog"所製作之Script修改而來
#----------------------------------------------
#設定Gmail帳號&密碼
:local GUser "Gmail_UserName"
:local GPass "Gmail_PassWord"
#寄件人
:local MailFrom "From@exam.com"
#收件人
:local MailTo "example@exam.com"
#寄出後是否刪除已存檔的Log(/file裡的檔案)
#0=保留 1=刪除
:local DeleteLogFile 1
:local BackupFileName
:set BackupFileName ([/system identity get name] . "_Backup-" . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".backup");
/system backup save name=($BackupFileName);
delay 10;
/tool e-mail set address=74.125.129.108 port=587 start-tls=yes
/tool e-mail set user=$GUser
/tool e-mail set password=$GPass
/tool e-mail set from=$MailFrom
/tool e-mail send to=$MailTo subject=([/system identity get name] . " -- RouterOS Backup " . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]) file=[$BackupFileName];
:delay 10;
:if ($DeleteLogFile =1) do={
/file rem [/file find name=($BackupFileName)];
}
:log info ("System Backup emailed at " . [/sys cl get time] . " " . [/sys cl get date] . " ");
#---
#---
打開 System/Schedule,建立新的排程,設定每日執行"gmail_backup_system"
成果!
設定完成後,可以檢視log確認是否運作正常
另外,再次提醒本Script只適用於Gmail
沒有留言:
張貼留言