Skip to content
MikroTik RouterOS Docs

Files

List all files:

/file print

Create a file (v7.9+):

/file add name=flash/myconfig.txt contents="my data here"

Create a backup:

/system backup save name=flash/my-backup

Export configuration to text file:

/export file=flash/config-export

Download file from URL:

/tool fetch url="https://example.com/script.rsc" dst-path=flash/script.rsc

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:

  1. Files are stored in the router’s flash memory or attached storage
  2. The /flash/ directory is persistent; files outside it may be lost on reboot
  3. Configuration can be saved as binary backup (.backup) or text export (.rsc)
  4. 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.rsc execute automatically when uploaded via FTP

Prerequisites:

  • Access to the router via Winbox, SSH, or terminal
  • FTP/SFTP service enabled for file transfers (optional)

/file print

Example 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:00
/file print detail where name~"backup"

For files under 60KB:

:put [/file get flash/config.rsc contents]
/file add name=flash/notes.txt type=file contents="Router installation notes"
/file add name=flash/backups type=directory
/file remove flash/old-config.rsc

Persistent 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.


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=SecurePass123

Create unencrypted backup:

/system backup save name=flash/router-backup dont-encrypt=yes

Restore backup:

/system backup load name=flash/router-backup.backup password=SecurePass123

Backup 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 exports create a human-readable script that can be edited and applied to different routers.

Export full configuration:

/export file=flash/full-config

Export with all defaults shown:

/export file=flash/full-config verbose

Export specific section (v7.13+):

/ip firewall filter export file=flash/firewall-rules

Export including passwords (v7):

/export file=flash/full-config show-sensitive

Test import first (dry run):

/import file-name=flash/config.rsc verbose=yes dry-run=yes

Apply configuration:

/import file-name=flash/config.rsc

/tool fetch url="https://upgrade.mikrotik.com/routeros/7.16/routeros-7.16-arm.npk" \
dst-path=flash/routeros-7.16-arm.npk
/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=yes
/tool fetch upload=yes url="sftp://10.0.0.100/backups/config.rsc" \
src-path=flash/config.rsc user=sftpuser password=sftppass

Files with the .auto.rsc extension uploaded via FTP execute automatically:

  1. Enable FTP service: /ip service enable ftp
  2. Upload script via FTP client with .auto.rsc extension
  3. Script executes and creates .auto.log file with results
# Check auto-import results
/file print where name~".auto.log"
:put [/file get myscript.auto.log contents]

/disk print

Example output:

# NAME LABEL FS SIZE FREE MOUNTED
0 usb1 BACKUP ext4 7.5GiB 6.2GiB yes

Format as ext4 (recommended):

/disk format usb1 file-system=ext4 label=BACKUP

Supported filesystems: ext4, fat32, exfat, xfs, btrfs (requires rose-storage package)

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"

Always eject before physically removing:

/disk eject usb1

Share files from the router via HTTPS using MikroTik’s cloud service.

/ip cloud set ddns-enabled=yes
/ip cloud back-to-home-file add path=usb1/shared enable=yes
/ip cloud back-to-home-file print

The share URL will be displayed as an HTTPS link through MikroTik’s cloud.

/ip cloud back-to-home-file remove [find path=usb1/shared]

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"

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=32768

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:

  1. Match RouterOS versions when restoring
  2. Use text exports for cross-device migration
  3. Reset MAC addresses after restore if needed

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=pass

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=pass

Symptom: Uploaded .auto.rsc file doesn’t execute.

Causes:

  • Uploaded via Winbox instead of FTP
  • Wrong filename extension
  • FTP service disabled

Solution:

  1. Enable FTP: /ip service enable ftp
  2. Upload via FTP client (not Winbox)
  3. Verify filename ends with .auto.rsc
  4. Check .auto.log for execution results

# 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"
# 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 removal

Files management in RouterOS covers:

  1. File storage - Use /flash/ for persistent storage on flash devices
  2. Backups - Binary for full restore, text export for portability
  3. File transfer - FTP, SFTP, HTTP via /tool fetch
  4. External storage - USB drives formatted with ext4 for expanded capacity
  5. Auto-import - .auto.rsc files 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