dockersnapshotbtrfs

send/receive subvolume with snapshots (btrfs)


btrfs subvolumes are great, and can be nested. Docker has support for btrfs and makes heavy use of nested snapshots.

I'm trying to move my /var/lib/docker to a new drive.

The procedure "should" be.
1- make a ro snapshot of /var/lib/docker

btrfs sub snap create /var/lib/docker /var/snapshots/docker_some_datetime

both source and destination are on the same fs.

2.- send the snapshot to the new drive

btrfs send /var/snapshots/docker_some_datetime | btrfs receive /mnt/drive2/snapshots/

inside docker folder, there is a btrfs folder filled up with subvolumes. I expected that the folder inside the snapshot be subvolumes as well, but they appear to be just regular folders.

;TLDR
So, the question is, If I take a snapshot of a subvolume that has subvolumes nested inside, aren't they supposed to be subvolumes as well in the snapshot? Am I hitting a btrfs limitation here?


Solution

  • Let's think of BTRFS-Subvolumes as "normal" partitions for a second and look at an example:

    Even if the first partition is not mounted, you can still take a backup of it.

    As BTRFS-Subvolumes are handled similarly to partitions, a recursive btrfs-send (that includes currently "mounted" Subvolumes) is more complicated.

    To my knowledge, there is no built-in function to do this with just one command.

    I once digged through the BTRFS backup tools mentioned on the wiki and as far as I recall one of those tools has exactly that feature: https://btrfs.wiki.kernel.org/index.php/Incremental_Backup#Available_Backup_Tools


    Now for BTRFS (as far as I understand it):

    (I put "mounted" several times in quotes as child Subvolumes get not really mounted - they're not visible as normal Linux mounts)