I've been experimenting with backing up and restoring Raspberry Pi SD cards.
There is of-course a very easy way: use "dd" or similar to create a disk image. However it has three disdvantages; it is slow, and it creates very large backups. And it's hard to extract individual files from the backups.
I've written up a quick process [1] for doing it manually, which is essentially: 1. Backup (or restore) the partitions using sfdisk 2. (Restore only) Create the filesystems on the destination 3. Backup (or restore) the files using tar.
However I'd like some advice on scripting and improving it.
In particular, this process creates three files (one for the partition info, and one each for the files from the two partitions). I'd like to end up with a single file, which I can do by just tar'ing the three at the end, but given the size of the files I want to keep the use of temporary files to a minimum.
Also, at the moment it's quite inflexible in terms of restoring to a different sized card, but ought not be.
But regardless, I figured there'd be enough Pi users around here who might find it useful.
(Use at your own risk, it's had very limited testing so far.)
[1] https://docs.google.com/document/d/e/2PACX-1vRk_zldu0Ra6MEEepTSKCzD55ANeasQO...