So I have a zpool in a direct attached storage enclosure that I use as an additional backup, but since it's quite slow I only run this once a month or so when I have time to just leave it running, by turning it on, importing, running the backup then exporting again, periodically running a scrub as well to check that everything's okay.
However, I currently do this manually, whereas what I'd really like to be able to do is just flick the switch to turn the enclosure on and have it be imported then scrub/backup and export, all automatically.
I know all the commands I'd need to put into a script, but what I don't know is how to trigger it; since the volume(s) on the pool don't mount automatically I can't use launchd's OnMount option, so what are the alternatives? I'd like to avoid polling the zpool command looking for the pool to be found, though I don't mind doing that if I can at least trigger the polling to begin roughly around when the enclosure is switched on (rather than running all the time).
Does anyone know of a way to detect when a zpool becomes available (as it becomes available) to import and/or have it import automatically such that I can then run my script?