Files
zfs-automatic-snapshots/README.md

1.5 KiB

README

zfs-auto-snapshot automatically creates and rotates periodic snapshots of all ZFS filesystems and volumes.
The script automatically rotates snapshots by pruning older ones beyond the retention limit.
The script temporarily skips snapshots on damaged pools or pools with an active scrub.

It creates:

  • 4 snapshots per hour (rotated every 15 minutes)
  • 24 hourly snapshots
  • 31 daily snapshots
  • 12 weekly snapshots
  • 12 monthly snapshots

Script is tested on Linux (AlmaLinux 9, CentOS/RHEL 7-9, OpenZFS 2.x / 0.8.x).
Originally adapted from https://github.com/zfsonlinux/zfs-auto-snapshot

Installation

make install

Configuration

Snapshot retention limits can be configured in zfs-auto-snapshot.conf:

  • KEEP_FREQUENT: snapshots rotated every 15 minutes (default: 4)
  • KEEP_HOURLY: hourly snapshots (default: 24)
  • KEEP_DAILY: daily snapshots (default: 31)
  • KEEP_WEEKLY: weekly snapshots (default: 12)
  • KEEP_MONTHLY: monthly snapshots (default: 12)

To apply configuration changes and update installed cron files, run:

make install

Uninstallation

make uninstall

Note

Uninstalling the script does not delete existing snapshots.

CLI Parameters

  • --keep: Number of snapshots to preserve (default: 10).
  • --label: Label tag for snapshots (default: defaultLabel).
  • --threshold: Minimum bytes written to the dataset since the last snapshot to trigger a new one (default: 0).
  • --prefix: Snapshot name prefix (default: zfs-auto-snap).