Compare commits
3 Commits
5106197dc6
...
86d600864d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86d600864d | ||
|
|
fc482a088b | ||
|
|
bcae740611 |
21
README.md
21
README.md
@ -18,17 +18,16 @@ Script to check zfs snapshot counts and age of oldest most recent snapshot. Spec
|
||||
|
||||
## 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
|
||||
```
|
||||
- `-d, --dataset <dataset>`: Dataset to check (required; can be repeated 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
|
||||
- `-e, --exclude <dataset>`: Exclude dataset (can be repeated for multiple)
|
||||
- `-v, --verbose`: Show detailed table
|
||||
- `-n, --err-for-no-snapshots`: Error if no snapshots found
|
||||
- `-h, --help`: Show help message
|
||||
|
||||
## Timestamp Formats (`-f`)
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ ERR_FOR_NO_SNAPSHOTS=false
|
||||
FORMAT=""
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 -d|--dataset <dataset> [-d|--dataset <dataset>...] [-p|--prefix <prefix>] [-f|--format <format>] [-m <duration>] [-s|--max-snapshots <num>] [-e|--exclude <dataset>] [-r|--recursive] [-v|--verbose] [-n|--err-for-no-snapshots]"
|
||||
echo "Usage: $0 -d|--dataset <dataset> [-d|--dataset <dataset>...] [-p|--prefix <prefix>] [-f|--format <format>] [-m <duration>] [-s|--max-snapshots <num>] [-e|--exclude <dataset>] [-r|--recursive] [-v|--verbose] [-n|--err-for-no-snapshots] [-h|--help]"
|
||||
echo " -d, --dataset ZFS dataset to check (can be specified multiple times)"
|
||||
echo " -e, --exclude Dataset to exclude (can be specified multiple times)"
|
||||
echo " -p, --prefix Snapshot prefix (default: zrepl_)"
|
||||
@ -27,6 +27,7 @@ usage() {
|
||||
echo " -r, --recursive Include all sub-datasets of specified datasets"
|
||||
echo " -v, --verbose Print per-dataset snapshot count and age"
|
||||
echo " -n, --err-for-no-snapshots Return error if any dataset has no snapshots"
|
||||
echo " -h, --help Show this help message"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@ -44,20 +45,6 @@ duration_to_seconds() {
|
||||
esac
|
||||
}
|
||||
|
||||
# timestamp_to_epoch() {
|
||||
# # Format: YYYYMMDD_HHMMSS_mmm
|
||||
# local timestamp="$1"
|
||||
# local year="${timestamp:0:4}"
|
||||
# local month="${timestamp:4:2}"
|
||||
# local day="${timestamp:6:2}"
|
||||
# local hour="${timestamp:9:2}"
|
||||
# local minute="${timestamp:11:2}"
|
||||
# local second="${timestamp:13:2}"
|
||||
|
||||
# # Convert to epoch using date command (assuming UTC)
|
||||
# date -u -d "${year}-${month}-${day} ${hour}:${minute}:${second}" +%s 2>/dev/null
|
||||
# }
|
||||
|
||||
# Format age in seconds to human-readable format
|
||||
format_age() {
|
||||
local total_seconds="$1"
|
||||
@ -356,6 +343,7 @@ if [[ "$VERBOSE" == "true" ]]; then
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "Datasets processed: ${#DATASETS_TO_PROCESS[@]}"
|
||||
echo "Max snapshots: $MAX_SNAPSHOT_COUNT ($MAX_SNAPSHOT_DATASET)"
|
||||
echo "Oldest most recent snapshot age: $TIME_DIFF_FORMATTED ($OLDEST_SNAPSHOT_DATASET)"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user