Backup By Gmail – Mikrotik

UPDATED on Apr/05/2016  ( few correction and add suggestions ( receiver email field)

Tested on # apr/03/2016 14:47:25 by RouterOS 6.34.4

Adding script into script section …
open new terminal and copy bellow lines

/system script
add name=BackupEmail source="# Enter Sender/Receiver Details.\r\
    \n:global gmailuser  GMAILUSERNAME\r\
    \n:global gmailid\r\
    \n:global gmailpwd  YOURCURRENTPASSWORD\r\
    \n## --- Do not change below ---- ##\r\
    \n# Enter Receiver  Details.\r\
    \n:global recmail RECEIVEREMAILADDRESS\r\
    \n## --- Do not change below ---- ##\r\
    \n#:log warning \"Mikrotik Router Backup JOB Started . . . \"\r\
    \n:local gmailip\r\
    \n:set gmailip [:resolve \"\"]\r\
    \n:global backupfile configbackup\r\
    \n:global mikrotikexport mtexport_backup\r\
    \n:global sub1 ([/system identity get name])\r\
    \n:global sub2 ([/system clock get time])\r\
    \n:global sub3 ([/system clock get date])\r\
    \n:log warning \"Creating new up to date backup files . . . \"\r\
    \n/system backup save dont-encrypt=yes name=\$backupfile\r\
    \n/export compact file=\$mikrotikexport\r\
    \n/tool e-mail set address=\$gmailip from=\$gmailid password=\$gmailpwd port=587 start-tls=yes user=\$gmailuser\r\
    \n:log warning \"Backup process pausing for 10s so it can complete creating backup if system is busy ...\"\r\
    \n:delay 10s\r\
    \n:log info \"Start Sending Backup File via Email using GMAIL SMTP . . .\"\r\
    \n/tool e-mail send to=\$recmail password=\$gmailpwd subject=\"\$sub3 \$sub2 \$sub1 Configuration BACKUP File\" from=\$gmailid file=\$backupfile server=\$gmailip start-tls=yes\r\
    \n:delay 30s\r\
    \n/tool e-mail send to=\$gmailid password=\$gmailpwd subject=\"\$sub3 \$sub2 \$sub1 Configuration EXPORT File\" from=\$gmailid file=\$mikrotikexport server=\$gmailip start-tls=yes\r\
    \n# Delete Old backup files to save space.\r\
    \n/file remove \$backupfile\r\
    \n:delay 30s\r\
    \n/file remove \$mikrotikexport\r\
    \n/tool e-mail set address= from=<> password=xxxx port=25 start-tls=yes user=yourid\r\
    \n:log warning \"Backup Finished & Backup File Removed. All Done. You should verify your inbox for confirmation\""

Now add Schedule to run every night 12:05 AM

/system scheduler
add interval=1d name=BackupByEmail on-event=BackupEmail start-date=apr/03/2016 start-time=00:05:00

Now it’s time to edit script and change some needed information about your GMAIL account


New Field Edit

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

Leave a Reply

Please log in using one of these methods to post your comment: Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.