Files
TL;DR (Quick Start)
Section titled “TL;DR (Quick Start)”List all files:
/file printCreate a file (v7.9+):
/file add name=flash/myconfig.txt contents="my data here"Create a backup:
/system backup save name=flash/my-backupExport configuration to text file:
/export file=flash/config-exportDownload file from URL:
/tool fetch url="https://example.com/script.rsc" dst-path=flash/script.rscOverview
Section titled “Overview”What this covers: Managing files on your MikroTik router, including creating files and directories, creating backups, exporting/importing configurations, transferring files via FTP/SFTP, and managing external storage.
When to use this:
- Creating and restoring configuration backups
- Exporting configurations for documentation or migration
- Uploading scripts and packages to the router
- Managing external USB drives for expanded storage
- Automated backup scripts with FTP/SFTP upload
How it works:
- Files are stored in the router’s flash memory or attached storage
- The
/flash/directory is persistent; files outside it may be lost on reboot - Configuration can be saved as binary backup (.backup) or text export (.rsc)
- Files can be transferred via FTP, SFTP, HTTP, or Winbox drag-and-drop
Key concepts:
- Binary backup (.backup): Full configuration including passwords, restorable only on same model
- Text export (.rsc): Human-readable script, portable across devices
- Flash storage: Persistent storage survives reboot; use
/flash/prefix - Auto-import: Files ending in
.auto.rscexecute automatically when uploaded via FTP
Prerequisites:
- Access to the router via Winbox, SSH, or terminal
- FTP/SFTP service enabled for file transfers (optional)
Part 1: Viewing and Managing Files
Section titled “Part 1: Viewing and Managing Files”List All Files
Section titled “List All Files”/file printExample output:
# NAME TYPE SIZE CREATION-TIME 0 flash directory jan/15/2026 10:00:00 1 flash/skins directory jan/15/2026 10:00:00 2 flash/pub directory jan/15/2026 10:00:00 3 flash/backup-20260115.backup .backup 45.2KiB jan/15/2026 12:30:00 4 flash/config.rsc .rsc 12.4KiB jan/15/2026 12:35:00View File Details
Section titled “View File Details”/file print detail where name~"backup"View File Contents
Section titled “View File Contents”For files under 60KB:
:put [/file get flash/config.rsc contents]Create a File (v7.9+)
Section titled “Create a File (v7.9+)”/file add name=flash/notes.txt type=file contents="Router installation notes"Create a Directory
Section titled “Create a Directory”/file add name=flash/backups type=directoryDelete a File
Section titled “Delete a File”/file remove flash/old-config.rscPersistent Storage
On flash-based devices, only files in the /flash/ directory persist across reboots. Files stored elsewhere reside in RAM and will be lost when the router restarts.
Part 2: Configuration Backups
Section titled “Part 2: Configuration Backups”Binary Backup (Full Restore)
Section titled “Binary Backup (Full Restore)”Binary backups contain the complete configuration including passwords, certificates, and user data. They can only be restored on the same router model.
Create encrypted backup:
/system backup save name=flash/router-backup password=SecurePass123Create unencrypted backup:
/system backup save name=flash/router-backup dont-encrypt=yesRestore backup:
/system backup load name=flash/router-backup.backup password=SecurePass123Backup Restores MAC Addresses
Binary backups include and restore the original MAC addresses. After restoring on a different device, you may need to manually reset MAC addresses.
Text Export (Portable Configuration)
Section titled “Text Export (Portable Configuration)”Text exports create a human-readable script that can be edited and applied to different routers.
Export full configuration:
/export file=flash/full-configExport with all defaults shown:
/export file=flash/full-config verboseExport specific section (v7.13+):
/ip firewall filter export file=flash/firewall-rulesExport including passwords (v7):
/export file=flash/full-config show-sensitiveImport Configuration Script
Section titled “Import Configuration Script”Test import first (dry run):
/import file-name=flash/config.rsc verbose=yes dry-run=yesApply configuration:
/import file-name=flash/config.rscPart 3: File Transfer
Section titled “Part 3: File Transfer”Download Files from URL
Section titled “Download Files from URL”/tool fetch url="https://upgrade.mikrotik.com/routeros/7.16/routeros-7.16-arm.npk" \ dst-path=flash/routeros-7.16-arm.npkUpload to FTP Server
Section titled “Upload to FTP Server”/tool fetch address=10.0.0.100 src-path=flash/router-backup.backup \ user=ftpuser password=ftppass mode=ftp \ dst-path=/backups/router-backup.backup upload=yesUpload via SFTP
Section titled “Upload via SFTP”/tool fetch upload=yes url="sftp://10.0.0.100/backups/config.rsc" \ src-path=flash/config.rsc user=sftpuser password=sftppassAuto-Import Scripts
Section titled “Auto-Import Scripts”Files with the .auto.rsc extension uploaded via FTP execute automatically:
- Enable FTP service:
/ip service enable ftp - Upload script via FTP client with
.auto.rscextension - Script executes and creates
.auto.logfile with results
# Check auto-import results/file print where name~".auto.log":put [/file get myscript.auto.log contents]Part 4: External Storage
Section titled “Part 4: External Storage”List Attached Disks
Section titled “List Attached Disks”/disk printExample output:
# NAME LABEL FS SIZE FREE MOUNTED 0 usb1 BACKUP ext4 7.5GiB 6.2GiB yesFormat External Drive
Section titled “Format External Drive”Format as ext4 (recommended):
/disk format usb1 file-system=ext4 label=BACKUPSupported filesystems: ext4, fat32, exfat, xfs, btrfs (requires rose-storage package)
Use External Storage
Section titled “Use External Storage”After formatting, access files at the disk name prefix:
# Save backup to USB drive/system backup save name=usb1/router-backup
# List files on USB/file print where name~"usb1"Safely Remove Drive
Section titled “Safely Remove Drive”Always eject before physically removing:
/disk eject usb1Part 5: File Sharing (v7.15+)
Section titled “Part 5: File Sharing (v7.15+)”Share files from the router via HTTPS using MikroTik’s cloud service.
Enable File Sharing
Section titled “Enable File Sharing”/ip cloud set ddns-enabled=yes/ip cloud back-to-home-file add path=usb1/shared enable=yesView Share URL
Section titled “View Share URL”/ip cloud back-to-home-file printThe share URL will be displayed as an HTTPS link through MikroTik’s cloud.
Disable File Share
Section titled “Disable File Share”/ip cloud back-to-home-file remove [find path=usb1/shared]Troubleshooting
Section titled “Troubleshooting”Problem 1: Files Disappear After Reboot
Section titled “Problem 1: Files Disappear After Reboot”Symptom: Files created on the router are gone after restart.
Cause: Files were stored outside the /flash/ directory on flash-based devices.
Solution: Always store persistent files in /flash/:
/file add name=flash/myfile.txt contents="persistent data"Problem 2: Cannot Edit Large Files
Section titled “Problem 2: Cannot Edit Large Files”Symptom: Error when setting contents of files larger than 60KB.
Cause: Direct content access is limited to 60KB.
Solution: Use chunked reads for large files, or edit files externally and upload:
# Read in chunks/file read file=largefile.txt offset=0 chunk-size=32768Problem 3: Backup Restore Fails
Section titled “Problem 3: Backup Restore Fails”Symptoms: Backup won’t restore or causes connectivity issues.
Causes:
- Version mismatch between backup and current RouterOS
- Backup from different hardware model
- MAC addresses restored from backup
Solutions:
- Match RouterOS versions when restoring
- Use text exports for cross-device migration
- Reset MAC addresses after restore if needed
Problem 4: FTP Upload Timeout
Section titled “Problem 4: FTP Upload Timeout”Symptoms: /tool fetch upload fails with timeout.
Causes: Passive mode issues, firewall blocking, wrong path.
Solutions:
# Verify connectivity/ping 10.0.0.100
# Check path is complete (include filename)/tool fetch address=10.0.0.100 src-path=flash/backup.backup \ dst-path=/backups/backup.backup upload=yes mode=ftp \ user=ftpuser password=passProblem 5: SFTP Upload “No Such File”
Section titled “Problem 5: SFTP Upload “No Such File””Symptom: Error “failure: closing connection: no such file”
Cause: URL must point to specific filename; directories must exist.
Solution:
# Correct: full path including filename/tool fetch upload=yes url="sftp://server/existing-dir/newfile.rsc" \ src-path=flash/config.rsc user=admin password=passProblem 6: Auto-Import Not Running
Section titled “Problem 6: Auto-Import Not Running”Symptom: Uploaded .auto.rsc file doesn’t execute.
Causes:
- Uploaded via Winbox instead of FTP
- Wrong filename extension
- FTP service disabled
Solution:
- Enable FTP:
/ip service enable ftp - Upload via FTP client (not Winbox)
- Verify filename ends with
.auto.rsc - Check
.auto.logfor execution results
Verification Commands
Section titled “Verification Commands”# List all files with details/file print detail
# Check available storage space/system resource print
# View specific file contents:put [/file get flash/notes.txt contents]
# List attached storage devices/disk print
# Verify backup exists/file print where type=".backup"
# Check auto-import logs/file print where name~".auto.log"Related Topics
Section titled “Related Topics”- System Backup - Detailed backup and restore procedures
- Scheduler - Automate backup scripts
- Tool Fetch - File download and upload
- FTP Service - Enable FTP access
Reference
Section titled “Reference”Official Documentation
Section titled “Official Documentation”Quick Reference Commands
Section titled “Quick Reference Commands”# File Operations/file print # List files/file add name=flash/file.txt contents="data" # Create file (v7.9+)/file add name=flash/dir type=directory # Create directory/file remove flash/file.txt # Delete file/file set myfile.txt contents="new data" # Edit file (<60KB)
# Backup/Restore/system backup save name=flash/backup # Create backup/system backup load name=flash/backup.backup # Restore backup/export file=flash/config # Export to text/import file-name=flash/config.rsc # Import from text
# File Transfer/tool fetch url="http://..." dst-path=flash/file # Download/tool fetch upload=yes src-path=flash/file ... # Upload
# External Storage/disk print # List disks/disk format usb1 file-system=ext4 # Format drive/disk eject usb1 # Safe removalSummary
Section titled “Summary”Files management in RouterOS covers:
- File storage - Use
/flash/for persistent storage on flash devices - Backups - Binary for full restore, text export for portability
- File transfer - FTP, SFTP, HTTP via
/tool fetch - External storage - USB drives formatted with ext4 for expanded capacity
- Auto-import -
.auto.rscfiles execute automatically via FTP upload
Key points:
- Files outside
/flash/may be lost on reboot (device-dependent) - Direct file content access limited to 60KB
- Binary backups restore MAC addresses
- Text exports are editable and portable across devices
- SFTP paths must include complete filenames