safer implementation

This commit is contained in:
2026-10-10 17:12:17 +02:00
parent 4a8181edc8
commit 9e698ca02a
8 changed files with 174 additions and 138 deletions

View File

@@ -1,33 +1,36 @@
# README #
zfs-auto-snapshot script creates automatic snapshots of all zfs filesystems and volumes.
The script will automatically rotate snapshots deleting old ones.
The script will temporarily avoid backups on damaged pools or pools with scrubbing going on.
`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 to rotate every 15 minutes
24 hourly snapshots
30 daily snapshots
12 weekly snapshots
12 yearly snapshots
- 4 snapshots per hour (rotated every 15 minutes)
- 24 hourly snapshots
- 31 daily snapshots
- 12 weekly snapshots
- 12 monthly snapshots
Script has been tested on zfs on linux 0.8.3, centos 7
Original script from https://github.com/zfsonlinux/zfs-auto-snapshot
I semplified the code and fixed some bugs
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
# to install
cd to current folder
## Installation
```sh
make install
```
# to uninstall
cd to current folder
## Uninstallation
```sh
make uninstall
```
# NOTE #
uninstalling the script doesn't delete made snapshots
> [!NOTE]
> Uninstalling the script does not delete existing snapshots.
in src folder, before installing, you can customize some parameters
--keep indicates the number of snapshots to save. Default to 10
--label indicates the label of snapshots. Default to defaultLabel
--threshold indicates how many bytes need to be written in a dataset after the last snapshot to allow new snapshots. Default 0
## 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`).