zfs-auto-snapshot(8)
Automatically create and manage ZFS snapshots on a configurable schedule.
Synopsis
zfs-auto-snapshot [OPTION]... [FILESYSTEM|VOLUME|SNAPSHOT]...Description
zfs-auto-snapshot is a shell script that automatically creates periodic snapshots of ZFS filesystems and volumes. It is typically run by cron at regular intervals (hourly, daily, weekly, monthly) and maintains a rolling set of snapshots by removing old ones based on configurable retention policies.
The command labels snapshots with a timestamp and frequency prefix (e.g., hourly-2024-01-15-14h30) and can be configured per-dataset using ZFS user properties to control snapshot frequency, retention count, and whether snapshots are taken recursively.
It integrates seamlessly with cron and systemd timers, and respects ZFS pool status, skipping snapshots if a pool is degraded or unavailable.
Common options
| Flag | What it does |
|---|---|
-a, --auto | Take snapshots of all datasets that have zfs-auto-snapshot:frequent, :hourly, :daily, :weekly, or :monthly properties set to 'true' |
-r, --recursive | Recursively take snapshots of filesystem and all its children |
-k, --keep NUM | Keep NUM recent snapshots of each dataset and delete older ones (default: 24 for hourly, 7 for daily, 4 for weekly, 12 for monthly) |
-f, --frequent | Create snapshots labeled 'frequent' (typically every 15 minutes) |
-h, --hourly | Create snapshots labeled 'hourly' |
-d, --daily | Create snapshots labeled 'daily' |
-w, --weekly | Create snapshots labeled 'weekly' |
-m, --monthly | Create snapshots labeled 'monthly' |
-n, --dry-run | Print commands that would be executed without actually creating or destroying snapshots |
-s, --syslog | Write log messages to syslog instead of stderr |
-e, --event | Use this for backup events (experimental, affects retention behavior) |
-p, --prefix STRING | Use custom snapshot name prefix instead of 'frequent', 'hourly', 'daily', etc. |
Examples
Take daily snapshots of all datasets marked with zfs-auto-snapshot:daily=true property
zfs-auto-snapshot -a -dRecursively take hourly snapshots of tank/home and all child datasets
zfs-auto-snapshot -r -h tank/homeDry run: show what daily snapshots would be taken without actually creating them
zfs-auto-snapshot -n -a -dTake hourly snapshots and keep the 48 most recent ones per dataset before pruning
zfs-auto-snapshot -a -h -k 48Enable automatic daily snapshots for tank/data dataset (then use with -a -d)
zfs set zfs-auto-snapshot:daily=true tank/dataTake monthly snapshots of all marked datasets and log events to syslog
zfs-auto-snapshot -a -m -sTake frequent snapshots of pool/vms recursively, keeping last 12 snapshots
zfs-auto-snapshot -r -f pool/vms -k 12Cron entry to run hourly snapshots every hour on all marked datasets
0 * * * * zfs-auto-snapshot -a -h >/dev/null 2>&1