rodri's place

ZFS Weekly Rolling Snapshots

I was recently looking for a way to incorporate rolling zvol disk snapshots for the grid's VMs and, after considering going my own way implementing my own scripts, I found out about zfsnap. Its operation is so simple that I just couldn't resist using it.

In the ports you'll find two versions of zfsnap, the 1.x and the 2.x. The 1.x is battle tested but more obscure, the 2.x has a nicer syntax and does the job. Feel free to read both of the scripts before you decide. I'm rolling with 2.x for now.

# pkg install zfsnap2

Now we make use of periodic(8)'s handy daily script to create new snaps and dispose of the old ones.

# cat <<EOF >/etc/daily.local
zfsnap snapshot -a 1w zroot/disk0 zroot/disk1 zroot/disk2 zroot/disk3
zfsnap destroy -r zroot
# chmod 700 /etc/daily.local

And that's it. you've got daily snapshots deleted every week.