In another thread it was noted that there seems to be no disk/partition cloning/imaging software tool that can really handle BTRFS volumes besides doing a 1:1 sector copy which has lots of drawbacks. “Really” here means that all subvolumes are being re-created when restoring.
So I am looking for a script which accepts a single parameter which is a mount point (e.g. \ or \mnt\dir).
Let’s name the script subvolbk. It will basically consider the output of sudo btrfs subvolume list <mount point>
It may throw an error if mount point does not match a top-level subvolume. Otherwise it should generate a list of btrfs subvolume create commands to recreate the subvolume structure on an empty top-level BTRFS volume.
# mkfs.btrfs -L "Clone" /dev/sdb2
# mount /dev/sdb2 /mnt/dst
# sh /tmp/sda2.btrfs.sh /mnt/dst
The output of btrfs subvolume list /mnt/dst should then be quite similar to that of btrfs subvolume list /mnt/src.
I hope this is understandable. Pointers to existing and already tested scripts are welcome and highly appreciated. Of course it doesn’t have to be a shell script, Python, Perl, whatever is fine.
Something I’ve always done when working with backup / imaging software I’ve not worked with:
a. Back it up
b. Restore it to a spare drive
c. Boot test the restored drive
Works? Yes - great. No - move on to the next thing.
Personally, I have /home on a separate XFS partition that gets backed up constantly.
The OS partition, (I use BTRFS for / ) I’m not concerned about - if it flounders, and can’t boot to a past restore point, I simply reinstall. Doing so is actually not very time consuming.
Actually I looked at btrbk when doing my research because it was mentionend in one of the threads that aggie posted. But I am surprised to see that it shall re-create subvolumes because in the README it says:
“Btrbk does not provide any mechanism to restore your backups, this has to be done manually.”