User Tools

Site Tools


Generic Backup

Backup system files

Please have a look at file_system and the flash layout details and take notice, that OpenWrt covers only the firmware part. The bootloader partition, ART/NVRAM and similar partitions are NOT part of the OpenWrt firmware. If something should go wrong and the data on these partition gets unexpectedly corrupted, you will not be able to replace it via public OpenWrt sources!

Since OpenWrt does not write to those partitions, it is very unlikely that they get corrupted by OpenWrt itself. However, if you mess around with the bootloader, you certainly should create a copy of this data on your PC. Otherwise, in case you lose that data, you would have to go to the forum, ask somebody to make a backup of his and send it to you, then you would have to replace the MAC address, and then flash it via port.JTAG, since your device would probably not boot any longer.

Create ART backup

If your ART-partition got corrupted, you would still be able to boot OpenWrt and only your wireless would not function correctly any longer. Easy fix with mtd.

dd if=/dev/$(grep -i '"art"' /proc/mtd |cut -c 1-4) of=/tmp/art.backup

If your bootloader-partition got corrupted, you would not even have a booloader console which you could only access through Serial Port any longer, and the only way to recover from this would be though the JTAG Port or by de-soldering the flash-chip, but please see generic.debrick for help.

However, once you've gotten yourself into the position to write to the flash again, you will still need something you can write to it. Something that will work. And here is, where your backup will come in handy:

dd if=/dev/mtd0 of=/tmp/boot.backup

Then copy your backup-file via scp or ssh to your PC and keep them safe for the time when you may need them.

Create Full MTD Backup

This script was made for Netgear WNR2000v4 and may need to be tweaked for other routers. It assumes a working SSH. Also, it connects 3 times so it's best to use an SSH key with this script. An improvement could be made by using rsync to have the remote files deleted after they are fetched in 1 command.

To customize, try looking at /proc/mtd in your router to see how many mtd partitions this script should look for, or look in /dev (ls /dev/mtd*) to see how many partitions there are (note the highest number). Change the second number of the "seq" command to match the highest /dev/mtd* partition number (eg. if highest is "/dev/mtd5", then change the "seq" command to "seq 0 5").

Also change the "ROUTER" variable value to the hostname/IP of your OpenWRT router.

On your local PC (not on the router), using a bash terminal (not Windows Command Prompt) create a new file (eg. ~/ containing the below script. Give this file execute privileges (chmod u+x and then execute it (./ This will backup your mtd contents to a zip file "" in the same folder as the script.


mkdir -p $BACKUP_DIR

ssh $USER@$ROUTER 'for i in `seq 0 6`; do
mtdname=`cat /proc/mtd | grep mtd$i | cut -d" " -f4 | sed s/\"//g`
echo "Backing up ${mtdname}"
dd if=/dev/mtd${i}ro of=/tmp/mtd${i}_${mtdname}.backup

scp $USER@$ROUTER:/tmp/mtd*.backup $BACKUP_DIR

echo 'Removing remote backup files'
ssh $USER@$ROUTER 'rm /tmp/mtd*.backup'

printf '\nZipping backup folder to\n'
zip -9mrv mtd_backup
printf '\n\nmtd backup complete.\nDont forget to unzip before restoring.\nunzip -v\n'

Create Backup from Bootloader

Sometimes it might be necessary to backup settings/partitions from original firmware. Depending on the bootloader, different strategies might be possible.

The flash-chip is mapped to a start adress. With uboot it should be in settings


  • memory dump to serial that is logged (uboot: md ; redboot: dump)
  • writing dumps to tftp or nfs

Restore Backup

from Bootloader console

Many bootloader allow you to work with mtd partition, but beware: they do not have to be identical with the Kernel mtd partitions! Also, with some bootloaders, you cannot use mtd-partition, you must work with offsets. In the latter case, it is probably a good idea to write down these correct offsets when you make the backups.

from OpenWrt console

mtd write art.backup art
Above method could work, but most probably will not as art partition is usually not writable, so you will have to compile you own kernel after doing some minor modification like described here: TL-WR1043ND or here: Then you must flash this to you device, boot it, and now the partition should be writable.


Backup OpenWrt configuration

You can backup your OpenWrt configuration through the web interface via System > Backup / Flash Firmware > Generate Archive. If the web interface is not available, connect using SSH and enter:

sysupgrade --create-backup /tmp/backup-`cat /proc/sys/kernel/hostname`-`date +%F`.tar.gz; ls /tmp/backup*

Now on your local computer, use scp to retreive the file: (Remember to use the ip of your OpenWRT device and the filename of your backup file.)

scp root@ .

You might also want to backup other files you have edited such as:

  • /etc/ethers
  • /home (if you added users)
  • /etc/config/firewall.user

see also /etc/sysupgrade.conf and ensure_desired_configuration_files_will_be_saved

Restore OpenWrt configuration

You can restore the previously saved OpenWrt configuration via

  • web interface: System > Backup / Flash Firmware > Backup / Restore
  • command line: …. FIXME
doc/howto/generic.backup.txt · Last modified: 2015/11/16 21:37 by tmomas