How to have ZFS make snapshots of a directory only when files are changed?

Is it possible to have ZFS make snapshots of a filesystem i.e. pool/filesystem/ only when files are changed? Instead of using cron or something to automatically create a snapshot every 5 minutes is it possible to have ZFS automatically take snapshots after a file has changed?

Is this possible and what would it involve? How would you do it?

Thanks in advance.


Solution 1:

Multiple Options:

1) cron based zfs diff (Solaris 11 Express++) and if something changed -> Snapshot() 2) dtrace zfs snapshot trigger

I have not done the latter, but read about it. 1) is probably the easiest way to do something, altought you might miss some changes, but you will not have snapshots with no changes piling up.

Regards, Robert

Solution 2:

First, you do not make snapshots of directories but (whole) file systems (or volumes) with ZFS. Moreover, even while snapshots are very lightweight with ZFS, triggering a snapshot for every file change would probably hurt performance unless your file system has a really low update rate. A file can be updated by a very large number of write operations, each of which would create a snapshot according to your requirements. I'm not sure thousands or millions of snapshots would be manageable.