Just trying to see what I can do to invent some kind of incremental block based backup solution out of the ground seeing that apparently it does not really exist for Linux.
I mean, it does not exist for me.
I just wrote a shell script that transforms dumpe2fs output into a list of used and unused block ranges:
- Code: Select all
$ ./e2zerocat.sh /dev/msata/boot
Of course many programs do this or something of the kind, such as partclone. But I didn't feel like learning someone's format right off the bat.
In effect it is easy to generate a (huge) stream of an entire volume by intermittent "dd" reads from the disk, and "dd" reads from /dev/zero, on stdout.
This would effectively be the same as catting the device itself, apart from the fact that all unused blocks have been zeroed!! That's why I call it "e2zerocat".
There are other solutions such as squashfs which is great for creating single backups but not for anything incremental wise.
In effect, you can create a sparse copy of a device by doing:
e2zerocat /dev/msata/boot | cp --sparse=always /dev/stdin outfile.sparse-dd
This will only read used blocks, and all others will be made sparse by cp.
Then you would have a sparse image file that you can mount with loopback!!.
It is just not compressed yet and I'm not sure how to accomplish that but for my purposes a sparse image of the filesystem (the entire device) is already very nice.
I mean how to mount a compressed image.
Besides, gzipping the file will un-sparsify it (it will just compress the zeroes).
So at that point I have a space efficient image.