Skip to content

Commit da5a8bd

Browse files
committed
Add --{pre,post}-snapshot for pre and post creation hook
1 parent d625c53 commit da5a8bd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/zfs-auto-snapshot.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ opt_setauto=''
3939
opt_syslog=''
4040
opt_skip_scrub=''
4141
opt_verbose=''
42+
opt_pre_snapshot=''
43+
opt_post_snapshot=''
4244

4345
# Global summary statistics.
4446
DESTRUCTION_COUNT='0'
@@ -156,8 +158,10 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
156158

157159
for ii in $TARGETS
158160
do
161+
do_run "$opt_pre_snapshot $ii $NAME"
159162
if do_run "zfs snapshot $PROPS $FLAGS '$ii@$NAME'"
160163
then
164+
do_run "$opt_post_snapshot $ii $NAME"
161165
SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
162166
else
163167
WARNING_COUNT=$(( $WARNING_COUNT + 1 ))
@@ -198,6 +202,7 @@ GETOPT=$(getopt \
198202
--longoptions=default-exclude,dry-run,fast,skip-scrub,recursive \
199203
--longoptions=event:,keep:,label:,prefix:,sep: \
200204
--longoptions=debug,help,quiet,syslog,verbose \
205+
--longoptions=pre-snapshot:,post-snapshot: \
201206
--options=dnshe:l:k:p:rs:qgv \
202207
-- "$@" ) \
203208
|| exit 128
@@ -308,6 +313,14 @@ do
308313
opt_verbose='1'
309314
shift 1
310315
;;
316+
(--pre-snapshot)
317+
opt_pre_snapshot="$2"
318+
shift 2
319+
;;
320+
(--post-snapshot)
321+
opt_post_snapshot="$2"
322+
shift 2
323+
;;
311324
(--)
312325
shift 1
313326
break

0 commit comments

Comments
 (0)