Script:
# GMAIL SMTP DYNAMIC Config Section, Make sure to change these values to match your's
:local GmailID "alertphalla@gmail.com"
:local GmailUser "alertphalla@gmail.com"
:local GmailPWD "XXXXXXX"
:local GmailPort "587"
:local ToAddr "phalla.ccmt@gmail.com"
:local GmailSMTP
:set GmailSMTP [:resolve "smtp.gmail.com"];
# Setting gmail options in tool email as well, useful when u dont have configured toosl email option
/tool e-mail set address=$GmailSMTP port=$GmailPort start-tls=yes from=$GmailID user=$GmailUser password=$GmailPWD
#GetDate
:local GDate [/system clock get date]
:local GDay [ :pick $GDate 4 6 ]
:local GMonth [ :pick $GDate 0 3 ]
:local GYear [ :pick $GDate 7 11 ]
:local GResult "$GDay $GMonth $GYear"
# file name for user manager backup
:local UserMan ([/system identity get name].".umb")
:log info $UserMan
# file name for system backup
:local BackupConf ([/system identity get name].".backup")
:log info $BackupConf
# file name for config export
:local ExportConf ([/system identity get name].".rsc")
:log info $ExportConf
# backup the data
/tool user-manager database save name=$UserMan overwrite=yes
:log info message="User manager backup finished (1/3).";
/system backup save name=$BackupConf
:log info message="System backup finished (2/3).";
/export compact file=$ExportConf
:log info message="Config export finished (3/3)."
# Send the user manager backup
:log info message="Sending user manager backup (1/3)."
#/tool e-mail send to=$ToAddr subject="Configuration BACKUP of $GResult-$UserMan" file=$UserMan start-tls=yes
# Send the system backup
:log info message="Sending system backup (2/3)."
/tool e-mail send to=$ToAddr subject="Configuration BACKUP of $GResult-$BackupConf" file=$BackupConf start-tls=yes
# Send the config export
:log info message="Sending config export (3/3)."
/tool e-mail send to=$ToAddr subject="Configuration BACKUP of $GResult-$ExportConf" file=$ExportConf start-tls=yes
# delay time to finish the upload - increase it if your backup file is big
:delay 3s;
:log info message="Configuration backup finished.";
Note:
You might got an error if your router does not install User-Manager. So you need to disable some config as below:
---------------------
#/tool user-manager database save name=$UserMan overwrite=yes
#/tool e-mail send to=$ToAddr subject="Configuration BACKUP of $GResult-$UserMan" file=$UserMan start-tls=yes
---------------------
No comments:
Post a Comment