Complete backup of system

I was Googling for a solution to making a complete backup of the system, so that one can get back to exactly the same point. I found this – is this still the way, or is there a more streamlined way?

From the video description:

cd /tmp

rm *.bin
dd if=/dev/mtd0 of=/tmp/uboot.bin
dd if=/dev/mtd1 of=/tmp/kernel.bin
dd if=/dev/mtd2 of=/tmp/rootfs.bin
dd if=/dev/mtd3 of=/tmp/rootfs_data.bin
dd if=/dev/mtd4 of=/tmp/art.bin
dd if=/dev/mtd5 of=/tmp/firmware.bin

lftp -e "put -O /router/images/ /tmp/uboot.bin; bye" -u username,password
lftp -e "put -O /router/images/ /tmp/kernel.bin; bye" -u username,password
lftp -e "put -O /router/images/ /tmp/rootfs.bin; bye" -u username,password
lftp -e "put -O /router/images/ /tmp/rootfs_data.bin; bye" -u username,password
lftp -e "put -O /router/images/ /tmp/art.bin; bye" -u username,password
lftp -e "put -O /router/images/ /tmp/firmware.bin; bye" -u username,password

#Copy Bin file to external storage if you have it
rm /mnt/16GB/openwrt-backup-BB/*.bin
rm /mnt/32GB/openwrt-backup-BB/*.bin
rm /mnt/150GB/openwrt-backup-BB/*.bin
cp -Rv /tmp/*.bin /mnt/16GB/openwrt-backup-BB
cp -Rv /tmp/*.bin /mnt/32GB/openwrt-backup-BB
cp -Rv /tmp/*.bin /mnt/150GB/openwrt-backup-BB

Have you tried the ordinary backup function in LuCi?

1 Like

If you mean the option under System > Backup/Restore, yes – but since it only creates a very small file (~6kB), I assume it only contains certain configurations. I would like a backup that when restored puts the system in exactly the same state as at the time of backup, including all extra packages, scripts etc.

is not correct for most modern devices, raw flash partitions with NAND flash may or may not work if you restore this backup.
NAND-based devices should use NAND-aware utilities, as dd does not properly handle the error correction or bad-block marking of NAND flash.

This must be done with nanddump tool (and written with nandwrite) to deal with nand ECC data

Also, the "backup mtd partition" from the Luci web interface is doing this (which is not correct for modern devices using NAND flash

Since also doing a firmware upgrade erases packages I've always used the Image Builder to make a full firmware image with all packages included, and at that point the only thing I need to backup/restore is the config files, which are handled by default Luci/OpenWrt backup system.


Just use imagebuilder (online) to get your firmware including all needed packages. And use the normal backup function. If you need some special files include them fia the config.


Yes DO NOT directly copy and restore mtd partitions on a device with NAND flash, that will brick it. On most routers with NOR flash you can make an image to clone or restore the installation with a copy of the "firmware" partition (which is an alias for kernel + rootfs + rootfs_data). Install this file with sysupgrade -n.

OpenWrt does not alter the bootloader, factory, or ART partitions so there is no need to restore those. Writing to these partitions can result in loss of unit-specific factory data that is difficult or impossible to recover.


Thanks to everyone. I have now found and read a number of instructive pieces that I recommend to anyone with the same question:

– and particularly

Between all of these, I think I'll figure out what works for me. I have already installed opkg extras and ensured that I extended the list of directories and files to be backed up; this made me understand why my backup file (with default settings) was so small.