Initial version
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# ZFS Snapshot Checker
|
||||
|
||||
Script to check zfs snapshot counts and age of oldest most recent snapshot. Specifically, this script iterates over a number of specified datasets, determines for each the age of the most recent snapshot (with a specified prefix), and then computes the maximum of those ages. This can be used to monitor zfs snapshotting and replication tools such as [zrepl](https://zrepl.github.io), [sanoid/syncoid](https://github.com/jimsalterjrs/sanoid/wiki). In addition, the script determines the number of snapshots for each specified dataset, as well as the maximum of those numbers. This facilitates monitoring of proper snapshot pruning.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
# Basic check
|
||||
./checkSnapshots.sh -d tank/data
|
||||
|
||||
# Recursive with verbose output
|
||||
./checkSnapshots.sh -d tank/data -r -v
|
||||
|
||||
# Provide limits (max 20 snapshots, max age 24h), resulting exit code 1, if limits are exceeded.
|
||||
./checkSnapshots.sh -d tank/data -s 20 -m 24h
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
```bash
|
||||
-d, --dataset <dataset> Dataset to check (required, repeat for multiple)
|
||||
-e, --exclude <dataset> Exclude dataset (repeat for multiple)
|
||||
-p, --prefix <prefix> Snapshot prefix (default: zrepl_)
|
||||
-f, --format <format> Timestamp format (see [below](#timestamp-formats--f))
|
||||
-s, --max-snapshots <num> Max snapshots per dataset
|
||||
-m, --max-age <duration> Max age (e.g., 31s, 17m, 24h)
|
||||
-r, --recursive Include sub-datasets
|
||||
-v, --verbose Show detailed table
|
||||
-n, --err-for-no-snapshots Error if no snapshots found
|
||||
```
|
||||
|
||||
## Timestamp Formats (`-f`)
|
||||
|
||||
- `zrepl-dense` - `20060102_150405_000`
|
||||
- `zrepl-human` - `2006-01-02_15:04:05`
|
||||
- `iso-8601` - `2006-01-02T15:04:05Z`
|
||||
- `unix-seconds` - Unix epoch
|
||||
- `sanoid` - default sanoid format
|
||||
|
||||
Without this flag, ZFS creation time will be used.
|
||||
|
||||
## License
|
||||
|
||||
MIT License - see [LICENSE](LICENSE)
|
||||
Reference in New Issue
Block a user