Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

4 Answers 4

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 at 3:03

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

share|improve this answer

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

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 at 3:02

Your Answer

 
discard

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.