I’ve got more zones than I know what to do with now, but they’re all interdependant.
I need to snapshot them all at the same time if I want to be able to rollback consistently.
Since it’s a backup it needs as few moving parts as possible.
I’m really more of a perl guy
As you saw yesterday, my shell scripting is pretty bloody awful.
But here’s a dead easy way to get daily snapshots across an entire storage pool.
vera bin # cat /opt/local/bin/citizensnaps
#! /bin/sh
ZPOOL=$1
if [ ! -n "$ZPOOL" ] ; then
echo 'Usage: $0 poolname' ; exit
fi
# check we have a pool with that name
/usr/sbin/zpool status $1 > /dev/null || exit
TODAY=`date +%A`
# get rid of last weeks snapshot, and create a fresh one
pfexec zfs destroy -r ${ZPOOL}@${TODAY}
pfexec zfs snapshot -r ${ZPOOL}@${TODAY}
Then run it out of roots crontab (or someone else with the correct rights profile) every night:
# daily snapshot of everything
59 23 * * * /opt/local/bin/citizensnaps tank
Bear in mind this is a dirt-simple, ‘works for me’ solution. If you want something more polished, look at Tim Fosters excellent work (which is making its way into Opensolaris ).

| Trackback