-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzman.sh
More file actions
123 lines (104 loc) · 2.9 KB
/
Copy pathzman.sh
File metadata and controls
123 lines (104 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
# ZMAN - ZFS Management Toolkit
# Author: Justin K Long
# https://github.com/thegfn
# Created: 2025-07-14
# Description: Modular CLI for managing ZFS
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/utils/log.sh"
source "$SCRIPT_DIR/lib/zfs.sh"
source "$SCRIPT_DIR/lib/zpool.sh"
source "$SCRIPT_DIR/lib/snapshot.sh"
source "$SCRIPT_DIR/lib/sendrecv.sh"
source "$SCRIPT_DIR/lib/replicate.sh"
source "$SCRIPT_DIR/lib/dataset.sh"
source "$SCRIPT_DIR/lib/pool.sh"
source "$SCRIPT_DIR/lib/report.sh"
print_usage() {
cat <<EOF
ZMAN - ZFS Management Toolkit
Usage:
zman <command> <subcommand> [options]
Commands:
dataset → Manage ZFS datasets (create, destroy, snapshot, etc.)
pool → Manage ZFS pools (status, scrub, attach, etc.)
report → Reporting tools for health, SMART, capacity, snapshots
snapshot
take --dataset <pool/dataset> [--name <snapname>] [--date]
→ Create a snapshot manually or with date-based naming
prune --dataset <pool/dataset> --days <N> / --keep-last <N>
→ Prune snapshots older than N days / keep the last N snapshots
send
--dataset <pool/dataset>
--snapshot <snapname>
--to <user@host:pool/dataset | /path/to/file.zfs>
[--incremental <snapname>] → Send incrementally from given snapshot
[--incremental-auto] → Auto-select most recent prior snapshot
[--compressed] → Use compressed send
[--mbuffer] → Stream with mbuffer
[--resume-token-file <file>] → Use resume token from file
[--dry-run] → Show what would be sent
receive
--dataset <pool/dataset>
--from <user@host:/path | /path/to/file.zfs>
[--mbuffer] → Use mbuffer for receive
[--dry-run] → Show what would be received
replicate
→ Run replication plan defined in plans/replication.conf
Per-dataset config keys:
- target = user@host:pool/dataset OR /path/to/file
- retain_days = <N>
- mbuffer = true|false
- incremental_auto = true|false
Examples:
zman snapshot take --dataset tank/data --date
zman snapshot prune --dataset tank/data --days 7
zman send --dataset tank/data --snapshot 2025-07-14 \\
--to user@remote:/backup/data --incremental-auto --mbuffer
zman receive --dataset tank/data --from /backups/incr.zfs
zman replicate
EOF
}
# Entrypoint dispatcher
if [[ $# -eq 0 ]]; then
print_usage
exit 0
fi
case "$1" in
dataset)
shift
dataset_cli "$@"
;;
pool)
shift
pool_cli "$@"
;;
report)
shift
report_cli "$@"
;;
snapshot)
shift
snapshot_cli "$@"
;;
send)
shift
zfs_send_cli "$@"
;;
receive)
shift
zfs_receive_cli "$@"
;;
replicate)
replicate_from_plan
;;
help | --help | -h)
print_usage
;;
*)
log_error "Unknown command: $1"
print_usage
exit 1
;;
esac