Backup Mikrotik Config to Email

-create System/Script/Backup2Email

:local backupfile mt_config_backup
:local mikrotikexport mt_export_backup
:local sub1 ([/system identity get name])
:local sub2 ([/system clock get time])
:local sub3 ([/system clock get date])
:local company “NGTrain”
:local adminmail1
:local gmailid
:local gmailuser ngtrain
:local gmailpwd Password123
:local gmailport 587
:local gmailsmtp
:set gmailsmtp [:resolve “”];
/tool e-mail set address=$gmailsmtp port=$gmailport start-tls=yes from=$gmailid user=$gmailuser password=$gmailpwd
:log warning “$company : Creating new up to date backup files . . . ”
/system backup save name=$backupfile dont-encrypt=yes
/export file=$mikrotikexport
:log warning “$company : Backup JOB process pausing for 10s so it can complete creating backup. Usually for Slow systems …”
:delay 10s
:log warning “Backup JOB is now sending Backup File via Email using GMAIL SMTP . . .”
# Start Sending email files, make sure you ahve configured tools email section before this. or else it will fail
/tool e-mail send to=$adminmail1 subject=”$sub3 $sub2 $sub1 Configuration BACKUP File” file=$backupfile start-tls=yes
/tool e-mail send to=$adminmail1 subject=”$sub3 $sub2 $sub1 Configuration EXPORT File” file=$mikrotikexport start-tls=yes
:log warning “$company : BACKUP JOB: Sleeping for 30 seconds so email can be delivered, ”
:delay 30s
# REMOVE Old backup files to save space.
/file remove $backupfile
/file remove $mikrotikexport

# Print Log for done
:log warning “$company : Backup JOB: Process Finished & Backup File Removed. All Done. You should verify your inbox for confirmation”

-create Scheduler
/system scheduler
add comment=”Scheduler for daily backup of MT” interval=1d name=daily-backup on-event=Backup2Email policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=jan/01/1970 start-time=00:00:00

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Google+ photo

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

Connecting to %s