0

I have a zfs pool called "data" on which I also put /var/lib/docker. Due to docker (in my case; for the sake of the question docker is irrelevant) zfs list looks something like this:

data                                                                        1.33G   133G      660M  /data
data/1366b029121dbc907878e8a6fc5c481244b7aac11757fe63b94384fe64e48c6d       6.02M   133G      511M  legacy
data/272a5f859a53ec996868fb0e4953f2219aadbd96c0cd3b8b9be09ee550b7d0e5        236K   133G      511M  legacy
data/284641b6a43d2446be81ddf21fbeb70b781f6fb5f70025d88c44c19ed4728541        288K   133G  
...

Now, if I perform a snapshot I do it with the recursive option (zfs snapshot -r data@snapshot-name) to have a snapshot of all datasets (mine - /data - and the docker ones).

By default snapshots are mounted in pool/.zfs/snapshot/snapshot-name.

Can I safely use pool/.zfs/snapshot/snapshot-name as a source directory for (consistent, thus the snapshot) backups or am I missing some data, respectively does zfs mount my snapshots recursively? I did not find anything in the docs.

1 Answer 1

1

Snapshots can be made recursively. But mounting a snapshot won't mount decedent snapshots. You can use a script to mount snapshots recursively to a specific directory, and then backup from there.

However, with regards to Docker, some data will be excluded using this method. Specifically the datasets with legacy mountpoint (and mountpoint set to none). ZFS won't automount them at boot and since the mountpoint doesn't contain a filesystem path (as opposed to /data in your example) it's not obvious where to mount their snapshots when performing a backup.

What I understand from this answer, is that Docker lagacy datasets contain the images for your containers. So you likely won't need to backup that data anyway.

Looking at your output from zfs list it seems you didn't make a dedicated dataset for Docker. That's why these Docker legacy datasets are stored under the parent dataset (the one you called data). I personally prefer to make a dedicated Docker dataset (could be under data too) to keep these legacy shares nested under the Docker dataset, like so:

zfs list -r data
NAME                                                                                    USED  AVAIL     REFER  MOUNTPOINT
data                                                                                   3.57G  2.63T      200K  /mnt/data
data/jip                                                                               2.27G  2.63T      208K  /mnt/data/jip
data/jip/docker                                                                         108M  2.63T     1000K  /mnt/data/jip/docker
data/jip/docker/4142fdca5ac3e7dbd12c0518e3377eb47a2c1a8599f564e07e08e5b25944146c        396K  2.63T      388K  legacy
data/jip/docker/43023791ce39ba890e8de50809cacda45a884b5990e4923fd6563eaed58e6b42        168K  2.63T      396K  legacy
data/jip/docker/98a9127ff2dd5fd2d0ea52f5e6343e85a8d2a80aa4cd2ffcf1c92e9b2d2b371f        101M  2.63T      102M  legacy
data/jip/docker/b68a666a8602cdbc3639b010558a0aa5f92f0b765a6efc15c4f7f30651ba2860       1.05M  2.63T      102M  legacy
data/jip/docker/b68a666a8602cdbc3639b010558a0aa5f92f0b765a6efc15c4f7f30651ba2860-init   216K  2.63T      102M  legacy
data/jip/home                                                                          2.16G  2.63T     36.9M  /mnt/data/jip/home

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.