I have written a cron job to automatically create snapshots of ZFS dataset on an hourly basis for critical files that benefit from active tracking.

The drawback of this is that these hourly snapshots create many redundant entries where no changes were made in the files or folders under the dataset.

I was wondering if its safe to assume that if the USEDSNAP property (usedbysnapshots) is equal to 0 then the snapshot contains no changes and can be deleted without loosing history.

  • 2
    You probably ought to check out sanoid before you reinvent the wheel again. – Michael Hampton Oct 29 at 19:23
  • Thanks Michael. sanoid looks exactly like the tool I need with the feature set I was looking for =) – Timothy C. Quinn Oct 29 at 19:50

If the snapshots are indeed empty, why bother deleting them in the first place?

Note that you cannot assume that if the snapshot size is listed as 0 that you won't lose any data. The size of the snapshot is the amount of data you can reclaim by deleting it. If data is added, then the snapshot removal will remove nothing, and snapshot size will be listed as 0. You will have to look at zfs diff output to establish whether anything has changed.

And finally, as Michael mentioned in the comment, you should seriously look at sanoid because it sounds like you are struggling with reinventing a wheel.

| 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.