The idea is good, but the proposed solution is too low level for my taste.
After the last crash last week I crafted a backup procedure because a re-flash costs too much time setting everything up again.
The procedure is as follows;
First prepare a backup SD card.
To prepare the card, the easiest way is to flash the lastest Zynthian image and start it in the device so it becomes a bootable system.
(******************
The less easy way is:
- prepare a 512Mb partition mmcblk0p1 and a partition mmcblk0p2 for the rest of the disk:
-Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 1056767 1048576 512M c W95 FAT32 (LBA)
/dev/mmcblk0p2 1056768 124735487 123678720 59G 83 Linux
mount the second partition as /mnt/sda2
- On this partition create the following directories:
sudo mkdir /mnt/sda2/proc
sudo mkdir /mnt/sda2/sys
sudo mkdir /mnt/sda2/tmp
sudo mkdir /mnt/sda2/run
sudo mkdir /mnt/sda2/mnt
sudo mkdir /mnt/sda2/boot
sudo mkdir /mnt/sda2/media
******************)
Put this prepared SD card in another linux device. This can be a RPi 3 or something else you have lying around. As long as a micro SD card fits it’s ok.
Then use rsync to copy your production system to this backup.
I use the following commands:
sudo mount /dev/sda1 /mnt/sda1
sudo mount /dev/sda2 /mnt/sda2
sudo rsync -aAXvn --exclude "/dev/*" --exclude /proc --exclude /sys --exclude /tmp --exclude /run --exclude /mnt --exclude /media --exclude /var/cache --exclude /boot --delete-after --exclude lost+found root@zynthian:/ /mnt/sda2/
sudo rsync -aAXvn --exclude /firmware --delete-after --exclude lost+found root@zynthian:/boot/ /mnt/sda2/boot/
sudo rsync -aAXvn --delete-after --exclude lost+found root@zynthian:/boot/firmware/ /mnt/sda1/
The above commands perform a dry run (they do everything except copying data).
When it looks ok, replace the rsync -aAXvn option by rsync -aAXv (remove the ‘n’) and run again. Now all data gets copied.
Take the newly created backup and test.
If it works, you have a working backup, that can be put back in case of emergency using the same procedure as before, with the corrupted disk as the target.
Well, I hope this makes some sense to you..
Kind regards,
Hans.