Is it possible to backup a btrfs partition verbatim (including all the shared structures which save space by marking snapshot trees as COW) to another one? For instance, I'd like to backup my root partition which has couple of btrfs subvolumes (snapshots of the / itself).
The only way I can think is to use a block copying tool like dd
but that is inefficient as my partition is only 20% full and I intend to back it up regularly. I already backup everything incrementally using rsync
, so this is not a workaround for another problem. I simply need a bit for bit clone of my btrfs partition without having to use a tool such as dd
.
I know ext3, for instance, provides a dump and restore utility. That is the kind of thing I'm looking for.
UPDATE
Here is a update to clarify the fact that I want to be able to access the files on the backup storage the same way I can on the live disk (ie I do not want to store dump files on the backup storage).
Best Answer
partclone is the tool you are looking for.
dd
it looks at the file systems allocation map (e.g.: FAT and exFAT's FAT tables, BTRFS extent maps, etc.) and clones only the used blocks.Depending on your usage pattern:
-b
(long:--dev-to-dev
) if both source and backup target black device are visible on the same machine (basically if both disks are plugged into the same computer).-c
and-r
(long:--clone
and--restore
) to first clone to partclone's own image format on the source machine, and then restore from the image on the backup machineA completely different way to handle the problem would be using
btrfs send
andbtrfs receive
mechanism.So btrfs' own mechanism isn't a sector perfect copy (unlike partclone's) but it's an extent perfect copy (much better than
rsynv -aSHAX
which only handles hardlinked files).