Optional: Generate a zfs mountpoint dedicated to your Mails:

$ zfs create zroot/usr/home/$USER/Mail

To create a snapshot (with a date as the seed) you can run:

$ zfs snapshot zroot/usr/home/$USER/Mail@$(date +%Y%m%d%H%M%S)offlineimap

Of course you need to point your ‘localfolders’ to a subdirectory of the zfs mountpoint you are generating a snapshot of.

Now you can easily wrap your offlineimap command with a failsafe like that:

#!/bin/sh
zfs snapshot zroot/usr/home/$USER/Mail@$(date +%Y%m%d%H%M%S)offlineimap
# append your commandline options as needed to the script
offlineimap $\*

TODO: Implement as offlineimap hook