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.

link|improve this question

79% accept rate
feedback

4 Answers

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

link|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 at 17:17
feedback

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.

link|improve this answer
+1, While possible, it's probably a bad idea as jlliagre mentioned. – Chris S Nov 23 '10 at 19:46
feedback

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.

link|improve this answer
feedback

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:

http://constantin.glez.de/blog/2010/04/how-automatically-update-your-home-media-server-library-dtrace

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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