1. To "clone" the entire OS and files, first do cat /proc/mtd to find which one is the "firmware" partition. That partition includes everything that OpenWrt modifies in the flash. You can create an image of the whole install from it:
root@NanoBeam:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00760000 00010000 "firmware"
mtd3: 00140000 00010000 "kernel"
mtd4: 00620000 00010000 "rootfs"
mtd5: 003e0000 00010000 "rootfs_data"
mtd6: 00040000 00010000 "cfg"
mtd7: 00010000 00010000 "EEPROM"
root@NanoBeam:/# cat /dev/mtd2 > /tmp/image.bin
The resulting image.bin can be flashed back to this router or to another router of exactly the same model to clone it. Treat it as a "sysupgrade" file.
This is for NOR flash only. It is very unlikely to work on NAND flash. Also if you only have 32 MB RAM, the image on the RAMdisk may cause the router to run out of RAM.
2. You can make the "backup" process include your files and scripts by referencing them in a file in /lib/upgrade/keep.d. Installed packages are by design not backed up, because when you change to a new version most packages need to be replaced with the ones built for the new version. Someone has written a script that basically formats the output of opkg --list-installed to a form that can be input to opkg install to reinstall upgraded packages.
(Last edited by mk24 on 9 Apr 2018, 16:50)