Detecting any changes on latest snapshot

Viewed 68

Is there a way to quickly check whether there are any changes made on top of the latest snapshot? The goal is to know whether taking another snapshot is necessary.

I have tried zfs diff $LATEST_SNAPSHOT but that approach seems unnecessarily complex since it prints everything, when I need a simple yes/no answer. Furthermore, zfs diff does not work on unmounted encrypted datasets.

1 Answers

You can use the command zfs get -o written <dataset> to see how much data has been written to <dataset> since its most recent snapshot was taken. If that value is zero, nothing has changed and you don't need another snapshot.

I think you might also be able to do it using the zfs get -o usedby* properties too, but I'm a little unclear about which one you'd want. If you want to try it, the zfsprops man page has very detailed descriptions of how space is accounted across those -- just search the page for usedby*.

Related