For the sake of completeness I am posting the code that I added to upgrade-wifi.sh and wich is responsible for the backup:
Code:
#
# Dump internal firmware on uSD
#
if [ -e /dev/mmcblk1p1 ]; then
# mount uSD (umount first just in case udevd has already mounted it in readonly)
umount /mnt/sd
dosfsck -a -w /dev/mmcblk1p1
mount -t vfat -o iocharset=utf8 /dev/mmcblk1p1 /mnt/sd
if [ -e /mnt/sd/KoboDump ]; then
# mount / as readonly and unmount internal FAT
mount -o remount,noatime,nodiratime,ro /dev/mmcblk0p1 /
umount /mnt/onboard
# test uSD: if mount failed, /mnt/sd/.123sdcheck123 can't be created since / is readonly
touch /mnt/sd/KoboDump/.123sdcheck123
if [ -e /mnt/sd/KoboDump/.123sdcheck123 ]; then
rm -rf /mnt/sd/KoboDump/.123sdcheck123
# dump...
dd if=/dev/mmcblk0 of=/mnt/sd/KoboDump/dump.img bs=512
# rename KoboDump to avoid (improbable) loops
mv /mnt/sd/KoboDump /mnt/sd/KoboDumpDone
fi
# restore mounted devices as expected
mount -o remount,noatime,nodiratime,rw /dev/mmcblk0p1 /
mount -t vfat -o iocharset=utf8 /dev/mmcblk0p3 /mnt/onboard
fi
umount /mnt/sd
fi