5

I often make snapshots of a ZFS volume (containing AOSP) make some changes (often extracting ZIP files over then top, or running scripts) and then run diff to see what has changed.

This is really easy with ZFS:

diff /mnt/vol /mnt/vol/.zfs/2017-10-18_snapshot

It takes a very long time when "vol" contains 63GB of mostly small files.

ZFS obviously has the information about which files are different, as the snapshots are Copy-on-Write.

Is there a ZFS-aware diff which can just ask ZFS for the answer?

4

Actually there is, and it's even named zfs diff (documentation and examples)

$ zfs diff tank/home/tim@snap1 tank/home/tim@snap2
M       /tank/home/tim/
+       /tank/home/tim/fileB

You can also diff between snapshot and live dataset, but only inside the same dataset and descendants, and only in valid temporal order (meaning old to new instead of new to old, just swap the arguments if it does not work at first). Possible results are:

M : File or directory has been modified or file or directory link has changed
- : File or directory is present in the older snapshot but not in the more recent snapshot
+ : File or directory is present in the more recent snapshot but not in the older snapshot
R : File or directory has been renamed

For filtering the results and using them in scripts, also see the example in the comment in my other answer on StackOverflow.

| improve this answer | |

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.