[Borgbackup] Edge cases in disk image example in documentation
Tomasz Melcer
liori at exroot.org
Sat Apr 14 17:47:42 EDT 2018
Hello,
I started looking at the suggested use of borg to back up disk images, [1].
[1]
https://borgbackup.readthedocs.io/en/stable/deployment/image-backup.html
I've noticed that the scripts shown there may have problems performing
backups correctly in some edge cases.
Firstly, the suggested scripts don't deal with extended partitions. Only
the main partition table is backed up. This may result in loss of data
or difficulties restoring the backups.
Secondly, the size of the header is defined as everything before the
"first" partition. However, the script considers the first partition as
the one listed as first in the partition table, and not the one that is
starting from the lowest sector. Curiously, the first partition in the
partition table doesn't have to be the one being "physically" the first
one on the disk. If this (rare) condition happens, the
`hostname-partinfo` archive will be needlessly big.
The way suggested by the `sfdisk` man page to deal with these problems
is to use its `--backup` switch — a bit bothersome to work with, but it
seems to work for me.
I have a script that performs a similar procedure and which has been
tested in these two corner cases. However, instead of storing partitions
as separate archives, it firstly builds a "clean" version of the disk
image, with zeroed-out sectors not used by filesystems or sectors
between partitions, and only then stores the clean image as an archive.
I found this procedure to be a bit more useful for my use case — I
noticed I can start a virtual machine and choose a disk image straight
from `borg mount`, which is pretty amazing!
I've posted my script at [2]. As it is different, it wouldn't outright
replace the scripts from the page linked above. If you think it's proper
to add it to the documentation next to the existing script, I'm willing
to submit a patch.
[2] https://gist.github.com/liori/ceac2a0c2fc7de1775a2585c4209f51b
--
Tomasz Melcer
More information about the Borgbackup
mailing list