100. Mikrotik Backup and Export Configuration to Gmail



You can contact me: plus.google.com/+PhallaCCMT; youtube.com/phallaccmt; facebook.com/Phalla.CCMT; twitter.com/PhallaCCMT and Phalla.CCMT@gmail.com

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
---------------------
Previous
Next Post »

7 comments

Write comments
arni
AUTHOR
May 7, 2017 at 2:31 PM delete

Hello


I have Mikrotik 750GR-3 I imported your script everything is ok except for executing files to memory


Logs show how less and the files on the disk do not appear can you help?

Reply
avatar
Unknown
AUTHOR
May 27, 2017 at 8:43 PM delete

Thanks for everything you offer. Please do a script to determine the amount of the quota in your Microtek and convert the customer after consumption to the Internet Chapter page with the possibility of specifying a certain number of gigs per customer

Reply
avatar
December 5, 2017 at 9:05 PM delete

the script he send the mikrotik configrantion backup but the src backup and and usermanger backup he not send it because its big,and appear timeout error...
when i increase the delay also not work..
how can i increase the timeout?

Reply
avatar
December 5, 2017 at 9:06 PM delete

the script he send the mikrotik configrantion backup but the src backup and and usermanger backup he not send it because its big,and appear timeout error...
when i increase the delay also not work..
how can i increase the timeout?

Reply
avatar
Unknown
AUTHOR
March 3, 2019 at 11:15 PM delete

This substance is composed exceptionally well. Your utilization of arranging while mentioning your focuses makes your objective facts clear and straightforward. Much obliged to you. Buy USA Gmail Accounts

Reply
avatar
August 5, 2019 at 1:26 AM delete

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. Sell Aged Used Gmail Accounts

Reply
avatar