sending_routeros_backup_file_via_email
This is an old revision of the document!
Table of Contents
Sending RouterOS Backup File via Email
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.
Script
: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"
Explanation
- Email Address: Set your destination email address where the backup will be sent.
- File Naming: The backup file name is generated using the router's name. Forward slashes would cause issues with file paths.
- Backup Creation: The script creates a backup file on the router.
- Email Sending: After a delay, the script sends the backup file via email.
- Cleanup: The backup file is removed from the router after the email is sent.
This script is useful for automating regular backups and ensuring they are securely stored off the router.
sending_routeros_backup_file_via_email.1724288106.txt.gz · Last modified: 2024/10/17 21:42 (external edit)
