First, you need current opkg installed packages:
https://forum.openwrt.org/viewtopic.php?id=42739
Then there are clues:
opkg list-changed-conffiles
And the overlay partition are full of changed files. Remember the extroot?:
tar -C /overlay -cvf - . | tar -C /mnt/sda1 -xf -
If you backup overlay, there is all the changes, so what I do is backup over netcat:
Ubuntu wrote:nc -l -p 10000 > overlay.tar
OpenWrt wrote:tar -C /overlay -cvf - . | nc 192.168.1.XXX 10000
But, I'd better compare current uci with default uci:
telnet 192.168.1.1
r=$(opkg list-installed base-files | sed -e 's/^.*-r//')
m=$(grep machine /proc/cpuinfo | sed -e 's/^.* //')
opkg list-installed | awk '{print $1}' > /tmp/opkg.txt
uci -d ";" -c/rom/etc/config show | sort > /tmp/default.uci
uci -d ";" show | sort > /tmp/latest.uci
opkg list-changed-conffiles > /tmp/changed-conffiles.txt
tar -C / -T /tmp/changed-conffiles.txt -czf /tmp/$m-$r.tar.gz -C /tmp opkg.txt default.uci latest.uci
rm /tmp/default.uci /tmp/latest.uci /tmp/opkg.txt /tmp/changed-conffiles.txt
cd /www
ln -sf /tmp/$m-$r.tar.gz
echo "# http://$(uci get network.lan.ipaddr)/$m-$r.tar.gz"
# http://192.168.1.1/TL-MR3220-44154.tar.gz
exit
After download, I compare both uci files, to keep only the minimal changes.
cd /tmp
cp -p TL-MR3220-44154.tar.gz [SOME-BACKUP-PATH]/ar71xx/r44154/
tar -xzf [SOME-BACKUP-PATH]/ar71xx/r39729/TL-MR3220-39729.tar.gz default.uci latest.uci
diff -U0 default.uci latest.uci | sed -e '/^@@\|^---\|^+++/ d' | sort -t = -k 1.2,1 -k 1.1,1.1 > uci.diff
# Delete every - folowed by +
awk -v FS="=" '/^-/ {
if ( found ) print found
found=$0
key=substr($1, 2)
}
/^+/ {
if ( found && substr($1, 2) != key ) print found
found=""
print
}' uci.diff | sed -e '/ / s/^\(.\)\(.*\)/\1"\2"/' | sed -e 's/^+/set /' -e 's/^-/delete /' > uci.batch
# LOL
gedit uci.batch
As you can see, from last line of code, there are spurious changes that shouldn't be there:
- Delete the network config, is automatically added after first boot.
- DELETE the shadow password, you likely not defined a password when restore this backup.
- UCI list: Require manual edit.
- ADD commit after every block.
This is an incomplete WIP code to copy and paste, is not a .sh script file.
Immediately after flash the newer revision, is a good practice to backup uci again, to avoid the defaults without network config. I call this "fresh.uci" instead of "latest.uci" and the /rom one "default.uci" isn't required.
Add a new Murphy law: You'll never have the "fresh.uci" needed for an upgrade
To restore is as simple as:
telnet 192.168.1.1
uci batch <<'EOF'
set system.@system[0].hostname=TL-MR3220
set system.@system[0].timezone=ART3
set "system.@system[0].zonename=America/Argentina/Buenos Aires"
set wireless.radio0.country=AR
set wireless.radio0.disabled=0
set wireless.radio0.distance=60
set wireless.radio0.txpower=17
set wireless.@wifi-iface[0].encryption=psk2+tkip+ccmp
set "wireless.@wifi-iface[0].key=Some long key."
set wireless.@wifi-iface[0].ssid=Some
commit system
commit wireless
EOF
reboot & exit