Trying to fully understand ZFS snapshots

Please help me get this straight.

Lets say I have a pool named pool1 with a dataset named dataset1.
I snapshot that dataset1 with snapshot1 before e.g. I make some big changes. Now, the old data “stays intact” and any new change is “recorded”. If I roll back to snapshot1, any change after that gets “deleted” and I am back to where I was, correct?

If I make a snapshot2 after my changes have been successful and I delete snapshot1, then the old “image” of the pool is gone and I continue on with my current configuration, right? If I delete both snapshots, the same thing happens, correct?

Now for the part I am having difficulty with:
I want to backup pool1 to pool2. Lets say pool2 is completely empty or at least does not contain dataset1. So I just send/receive snapshot1 from pool1 to pool2 and I get dataset1 on pool2.

After that, I keep working on dataset1 on pool1 and I make a second snapshot of dataset1 named snapshot2. I can send the differences between snapshot1 and snapshot2 to pool2 just fine BUT, what happens if I also make changes on pool2/dataset1 after snapshot1 but before snapshot2? ZFS probably will not let me send snapshot2 to pool2. How do you recover from such a situation? Would my only option be to revert to snapshot1 on pool2, losing the changes on pool2, in order to proceed?

Also, what would happen if I deleted snapshot1 on pool2? The data would be there but I would not be able to incrementally update from pool1/snapshot1 to pool1/snapshot2 on pool2. Would I have to delete the dataset on pool2 and send the snapshot2 all over again?

Bonus point: I have pool1/dataset1 with snapshot1 and I send dataset1 to pool2 via snapshot1. I delete pool1/dataset1 and keep pool2/dataset1. In the past, when I would try to send dataset1 back to pool1, I got some error about the parent snapshot not being available or something. What happens then?

You got it right there.
Zfs will reject the incremental replication, with an error like “data does not match snapshot” or “data changed since snapshot”

If there is no common snapshot, you would not be able to trace back, so yes, pool2 would have to be destroyed if you wanted to re-create it with a snapshot of pool1.

For the bonus question, not sure, but if pool1 still had some remnants of dataset1, that might be the stumbling block?
maybe dataset1 was not fully destroyed, and all children with it?
(nested datasets can be really cool, but get in the way a little bit)

1 Like