I’ve just updated the ZFS Automatic Snapshot SMF service that I wrote about before.

Now we’ve got support to only keep a fixed number of snapshots into the past, deleting older auto-snapshots. This also does the right thing if we’ve asked the service to snapshot all child datasets. Of course, we only look at snapshots that were created by this service, or at least ones that match our naming scheme (erm) when looking for older snapshots to delete. Perhaps I need to tidy that up…

Also new, though not hugely exciting (unless you’ve never seen SMF before, in which case you’ll love it!) is that the service method is now reasonably well-behaved. If any of the tasks inside the service method fail, we now move the service into maintenance
state, and wait till an administrator fixes it.

There’s still a bit more work to do here, in particular, I’d like to find out the correct way to log messages from the cron job to the correct SMF log for that instance of the service – just redirecting stdout and stderr into (say)
/var/svc/log/system-filesystem-zfs-auto-snapshot:space-timf.log just doesn’t seem right to me. Any ideas on the proper way to do that ?

timf@haiiro[571] svcs -l svc:/system/filesystem/zfs/auto-snapshot:space-timf
fmri         svc:/system/filesystem/zfs/auto-snapshot:space-timf
name         ZFS automatic snapshots
enabled      true
state        online
next_state   none
state_time   Tue May 30 13:58:35 2006
logfile      /var/svc/log/system-filesystem-zfs-auto-snapshot:space-timf.log
restarter    svc:/system/svc/restarter:default
dependency   require_all/none svc:/system/filesystem/local (online)
dependency   require_all/none svc:/system/cron (online)

No GUI changes as yet, but if you’d like to give this a go, you can download the latest tarball,

Comments and suggestions welcome!

Update 8th June: You probably want to see a recent post on this topic here