Generate backup and send it by e-mail - Mikrotik Script RouterOS

This script generates backup file and sends it to specified e-mail address. Mail subject contains router's name, current date and time.
Note that smtp server must be configured before this script can be used. See /tool e-mail for configuration options.

:log info "Starting Backup Script..."
:global backupfile ([/system identity get name] . ".backup")
:if ([/file find name=$backupfile] != "") do={/file rem $backupfile}
:delay 2s
/system backup save name=$backupfile
:log info "Waiting 5s for backup to complete..."
:delay 5s
:log info "Backup being emailed..."
/tool e-mail send to="" subject=([/system identity get name] . " Backup") file=$backupfile
:log info "Finished Backup Script!"