daily backup by gmail

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\r\
    \n:global gmailuser  GMAILUSERNAME\r\
    \n:global gmailid  YOUREMAILID@gmail.com\r\
    \n:global gmailpwd  YOURCURRENTPASSWORD\r\
    \n\r\
    \n## --- Do not change below ---- ##\r\
    \n\r\
    \n\r\
    \n# Enter Receiver  Details.\r\
    \n:global recmail RECEIVEREMAILADDRESS\r\
    \n\r\
    \n## --- Do not change below ---- ##\r\
    \n\r\
    \n#:log warning \"Mikrotik Router Backup JOB Started . . . \"\r\
    \n:local gmailip\r\
    \n:set gmailip [:resolve \"smtp.gmail.com\"]\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\r\
    \n/system backup save dont-encrypt=yes name=\$backupfile\r\
    \n/export compact file=\$mikrotikexport\r\
    \n\r\
    \n/tool e-mail set address=\$gmailip from=\$gmailid password=\$gmailpwd port=587 start-tls=yes user=\$gmailuser\r\
    \n\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=0.0.0.0 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

gmailuser GMAILUSERNAME
gmailid YOUREMAILID@gmail.com
global gmailpwd YOURCURRENTPASSWORD

New Field Edit
global recmail RECEIVEREMAILADDRESS

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group