Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 5 down vote accepted

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

share|improve this answer
You probably have to miss some changes. If you literally want to do a snapshot on every change, you'd have to create a snapshot every time a block was written. – James Moore May 6 '12 at 17:17
What's the ZFS snapshot limit? – CMCDragonkai Jun 27 '14 at 3:03

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.

share|improve this answer
+1, While possible, it's probably a bad idea as jlliagre mentioned. – Chris S Nov 23 '10 at 19:46
I'm looking to create an immutable filesystem, so I can keep the history of every single file change. Can ZFS do this? Don't worry about storage size, I'll archive the old ones. – CMCDragonkai Jun 27 '14 at 3:02
That sounds like something you should be implementing with a software layer above the filesystem. I don't know of any filesystem that provides a hard audit trail like that. It's not really the filesystem's job to try and glean meaning from read and write operations. – cathode Mar 3 '15 at 15:58

Couldn't you write a script to make a new snapshot, compare it to the last snapshot, and if nothing has changed, simply remove the snapshot? I am not certain how the comparison of the two snapshots would take place, but it seems like it should be simple.

share|improve this answer

Assuming you want to avoid snapshots every five minutes with unchanged files, you could implement a dtrace script triggered writes occur that create a flag file; then a script that runs periodically via cron which creates a snapshot when the flag file exists. Constantin Gonzalez wrote a blog entry which covers most of what you'd need to implement this:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.