This guide provides a script to automate the process of creating a backup on a RouterOS device, sending it as an email attachment, and then removing the backup file from the router.
:local emailAddress "[email protected]" :log info "BACKUP STARTING NOW" # Create the backup file :global backupfile ([/system identity get name]) /system backup save name=$backupfile :log info "BACKUP FILE SAVED AS $backupfile, SENDING EMAIL IN 5 SECONDS" :delay 5s # Send the backup file via email /tool e-mail send to="$emailAddress" subject=([/system identity get name] . " Backup " . [/system clock get date] . " " . [/system clock get time]) file=$backupfile :delay 15s :log info "EMAIL SENT, REMOVING BACKUP FILE" # Remove the backup file from the router /file remove $backupfile :log info "Backup file removed from router" :log info "Backup process completed"
Forward slashes would cause issues with file paths.
This script is useful for automating regular backups and ensuring they are securely stored off the router.