I am using ZFS on Linux, and have some question regarding snapshots. I have following structure

mypool/HOME mounts /home
mypool/HOME/root mounts /root
mypool/ROOT mounts none
mypool/ROOT/rootfs mounts /
mypool/ROOT/rootfs/OPT  mounts /opt
mypool/ROOT/rootfs/USR  mounts /usr
mypool/ROOT/rootfs/VAR mounts /var
mypool/docker mounts /var/lib/docker

I want to backup all of this by cron task when I run zfs snapshot -r mypool/HOME@today, it creates snapshot recursively. But after I copy something heavy to /home, and create another snapshot, it shows used 0 or a few kb.

I want to be sure, that it backups mypool/HOME and mypool/HOME/root. is the -r option works for both?

Same with docker. Docker have own snapshots/clones/subvolumes on it's volume. If I do zfs snapshot -r mypool/docker, will it backup all data as it is on this moment? If some subvolumes appear/disappear, can I restore the same state it was from snapshot?


According to man zfs:

-r Recursively create snapshots of all descendent datasets

So, zfs snapshot -r mypool/HOME@today will snapshot everything under mypool/HOME.

In your post, you use snapshot and backup interchangeably. Snapshots are not backups, and they should be 0kb on creation.

See this and particularly this for a good overview of snapshots, along with the ZFS man(8) page.

  • > will snapshot everything under mypool/HOME, but INCLUDING mypool/HOME, which is mounted as /home? Why I am asking this question, because I added a 30GB to /home and nothing changed in sizes in zfs list -t snapshot, after creating a new
    – Ural
    Feb 9 '17 at 9:18
  • Yes, it will snapshot every dataset descendant of mypool/home
    – airhuff
    Feb 9 '17 at 9:22
  • Thanks for answer. I hope snapshoting docker is also safe in this way
    – Ural
    Feb 9 '17 at 9:33
  • 1
    The snapshotting will work the same way for docker. If you are really new and uncomfortable with this stuff, create a dummy file system, take snapshots while adding data between each snapshot. cd into the snapshots (under the hidden .zfs folder) and look around. Play around with destroying snapshots, doing rollbacks, clones, promoting. With a dummy data set you have nothing to loose. The ZFS man page should have all you need to get started. You will be much more comfortable with ZFS if you do some playing around with it like this.
    – airhuff
    Feb 9 '17 at 20:16

Snapshots are no backups. Snapshots are what it says: a snapshot of the filesystem state at the time of the snapshot. So indeed it will show a very low usage. When you would delete big files or a lot, which are uniquely in the snapshot, you will see the snapshot usage increase.

  • 1
    I know it is not backups, but I think it is the best way to keep all data safe and have incremental history, if I have synced the FS and all snapshots to a remote
    – Ural
    Feb 9 '17 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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