The other day, Roger asked for an additional feature to be added to the ZFS Automatic Snapshots SMF service that I wrote. The feature was, the ability to configure multiple snapshot schedules per filesystem.

For example, I have a ZFS filesystem for which I’ve configured a snapshot service to take weekly snapshots, and keep them on the system for a few months. However, during the day, I also want to have the system take automatic hourly snapshots of that filesystem, but only keep perhaps snapshots from the last 6 hours.

“Easy!”, I thought – and started writing the suppport for the feature. Along the way, I also added support for the new snapshot -r ZFS feature now available in Solaris Nevada, which really speeds things up.

However, I quickly ran into a wall (ouch) when thinking about this feature. At the moment, each instance of the snapshot service configures a different set of automatic snapshots. For example, here’s what’s on my desktop :

root@haiiro[59] svcs auto-snapshot
STATE          STIME    FMRI
disabled       16:49:03 svc:/system/filesystem/zfs/auto-snapshot:space-test
online         16:08:55 svc:/system/filesystem/zfs/auto-snapshot:space-archive
online         16:08:55 svc:/system/filesystem/zfs/auto-snapshot:space-timf
online         16:08:55 svc:/system/filesystem/zfs/auto-snapshot:tank-root_files ystem
online         16:49:03 svc:/system/filesystem/zfs/auto-snapshot:default

The FMRI of each instance nicely delimits the boundaries of each set of snapshots – the instance names don’t have any special significance, other than to show what’s happening on the system at a glance. All the useful information I need in order to take snapshots are actually stored in instance-properties.

However, when I started to think about multiple instances for the same filesystem, I kept running into namespace clashes (other than these)

I can’t create instance names "svc:/system/filesystem/zfs/auto-snapshot:space-timf:hourly" or "svc:/system/filesystem/zfs/auto-snapshot:space-timf@hourly" or "svc:/system/filesystem/zfs/auto-snapshot:space-timf$hourly" – SMF doesn’t allow those characters in instance names.

I think I’m looking to subdivide the instance somehow – I’d thought of individual property groups inside each instance, each one corresponding to a different schedule for that filesystem, but then the granularity of the service breaks down: I couldn’t disable hourly snapshots while keeping the monthly snapshots enabled for a given filesystem. Maybe that’s okay ?

I’ll keep thinking about it. Along with that, I’m also still trying to find the best way for my cron job to log snapshot status into the SMF log – simply redirecting output from the cron script into each FMRI’s corresponding restarter/logfile doesn’t seem like the right thing to do. Perhaps more coffee will help – but otherwise, all thoughts are welcome!