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?
Let's think of BTRFS-Subvolumes as "normal" partitions for a second and look at an example:
/mnt/hdd
and a second partition is mounted at /mnt/hdd/nested
..img
or .iso
), this will not include the second partition just because it is currently mounted "inside" the first partition.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):
If you mount a BTRFS partition (e.g. via /etc/fstab
), by default it's top-level Subvolume get's mounted at the desired location.
And all Subvolumes residing inside the mounted BTRFS-Subvolume (by having a child-parent-relationship to the top-level Subvolume), get automatically "mounted" at a relative subpath as well.
Though not all Subvolumes of one BTRFS-device must always be visible: If you use the mount option subvolid=<ID-of-some-Subvolume>
, only child-Subvolumes are automatically "mounted" at a relative subpath.
(I put "mounted" several times in quotes as child Subvolumes get not really mounted - they're not visible as normal Linux mounts)