zfs-snap

zfs-snap periodically creates and deletes ZFS snapshots on a FreeBSD machine.

Installation

  1. Download 598.zfs-snap
  2. Move it to /usr/local/etc/periodic/daily or /usr/local/etc/periodic/weekly
  3. Make it executable

Configuration

Enable zfs-snap and specify one filesystem or volume at least in /etc/periodic.conf, e.g.:

zfs_snap_enable="YES"
zfs_snap_filesystems="zroot/usr zroot/home:3m zroot/var::1d zroot/data:2m:6H"
Every time zfs-snap is executed, it'll create a snapshot of the specified filesystems or volumes if given time contraints are met. Snapshots are named like zroot/usr@zs20161227-123242, i.e. current date and time. By default, zfs-snap allows you to create snapshots every second and will keep each snapshot for 1 month. In the above example, every time zfs-snap is invoked, snapshots... The generic format of zfs_snap_filesystems is:
zfs_pool[/filesystem_or_volume][:[retention][:frequency]]
Both retention and frequency accept any time adjustment which date allows (see option -v). In order to override the global default of 1 month for retention (the time period for which snapshots are kept by default), add this to /etc/periodic.conf:
zfs_snap_keep="6w"
Every snapshot will be kept for 6 weeks unless overridden by some entry within zfs_snap_filesystems.

Files