Prevent zfs take empty snapshot

Hi all,
I follow Wendell on YouTube and enjoy the content very much. :rose:

Recently I faced a problem which I couldn’t find a solution :cry:
I use zfs on linux which supports taking snapshot. Is there a way to to take snapshots only if there’s a change in the files? (I saw something in Truenas which says “don’t allow empty snapshots”)

NB. I use znapzend to snapshot my pools and replicate them to an off-site pool.

1 Like

Normally you want to take a snapshot even if no change has taken place. The snapshot will take up zero extra space, and the replication will be very fast. If you don’t take a snapshot it can cause issues with some retention algorithms for backup software (time based vs snapshot count based).

1 Like

Sorry you had a problem.

I generally agree with Cowphrase, to automatically take many snapshots (often will be empty) and automatically prune them.

Just make sure you dont prune too many, when replicating elsewhere, in case you loose common points…

Ignoring the problems with the snapshitting scripts relying on them being present instead of a log, one thing to note, is deleting snaps based on 0 “USED” has a gotcha: Is there any risk to deleting empty (0B) autosnaps? · Issue #616 · jimsalterjrs/sanoid · GitHub

When you see 0B USED on a snapshot, that does not mean it’s “empty.” That means that there are no blocks present in that snapshot that are not present in at least one other snapshot (including the live filesystem).

It is “safe” to delete a single snapshot which has 0B USED without risk of losing data. But you can’t delete another one “safely” until you do a new zfs list and recheck the USED for the nextsnapshot you’re thinking of deleting.

If empty snapshots are making things unreadable in the Cli, , may instead consider just filtering out the empty ones instead of deleting them. For a better way of looking through the contents of a snapshot, httm (“hot tub Time Machine”) is a neat tool.

1 Like