:local routerName [/system identity get name] :local version [/system package get routeros version] /system backup save name="$routerName-$version-[$/system clock get date].backup"
:local backupPassword "YourBackupPassword" :local ftpServer "192.168.1.100" :local ftpUser "backupuser" :local ftpPassword "YourFTPPassword"
1. Binary Backups vs. Script Exports: Understanding the Core Differences mikrotik backup restore better
2. Why Automated Strategies Are Better Than Manual Processes
Once your script is ready, you need to tell the router when to run it. This is done with system scheduler . For example, to run a script named "daily-backup" every day at 2 AM, you would use: :local routerName [/system identity get name] :local version
A human-readable text file containing a sequence of Terminal commands that rebuild the configuration.
Never store backups in plain text if they are leaving the router. In RouterOS v7, you can add a password directly to your export: export file=myConfig password=YourSecurePassword This ensures that if your backup is intercepted or stored on a cloud drive, your ISP credentials and VPN keys remain secure. Step B: Off-Box Storage (The "3-2-1" Rule) Why Automated Strategies Are Better Than Manual Processes
/system script add name="auto_secure_backup" policy=read,write,policy,test source= :local routerName [/system identity get name]; :local time [/system clock get time]; :local date [/system clock get date]; # Format date to prevent invalid characters in filenames :local months "jan"="01";"feb"="02";"mar"="03";"apr"="04";"may"="05";"jun"="06";"jul"="07";"aug"="08";"sep"="09";"oct"="10";"nov"="11";"dec"="12"; :local month [ :part $date 0 3 ]; :local day [ :part $date 4 6 ]; :local year [ :part $date 7 11 ]; :local monthNum ($months->$month); :local fileName ($routerName . "-" . $year . $monthNum . $day . "-" . [:pick $time 0 2] . [:pick $time 3 5] . ".backup"); # Generate encrypted binary backup /system backup save name=$fileName password="YourStrongEncryptionPassword"; # Wait for file creation to complete :delay 5s; # Securely upload to remote SFTP server /tool fetch mode=sftp address="192.168.1.50" port=22 user="backup_user" password="ServerPassword" src-path=$fileName dst-path=("/backups/" . $fileName) upload=yes; # Clean up local storage /file remove $fileName; :log info "Remote backup successfully uploaded: $fileName"; Use code with caution. Step 2: Schedule the Script to Run Automatically
System files, user passwords, encryption keys, and hardware-specific configurations.