mirror of
https://github.com/zfsonlinux/zfs-auto-snapshot.git
synced 2024-11-29 19:43:33 +01:00
Add --{pre,post}-snapshot
for pre and post creation hook
This commit is contained in:
parent
d625c53af1
commit
da5a8bd5b7
@ -39,6 +39,8 @@ opt_setauto=''
|
|||||||
opt_syslog=''
|
opt_syslog=''
|
||||||
opt_skip_scrub=''
|
opt_skip_scrub=''
|
||||||
opt_verbose=''
|
opt_verbose=''
|
||||||
|
opt_pre_snapshot=''
|
||||||
|
opt_post_snapshot=''
|
||||||
|
|
||||||
# Global summary statistics.
|
# Global summary statistics.
|
||||||
DESTRUCTION_COUNT='0'
|
DESTRUCTION_COUNT='0'
|
||||||
@ -156,8 +158,10 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
|
|||||||
|
|
||||||
for ii in $TARGETS
|
for ii in $TARGETS
|
||||||
do
|
do
|
||||||
|
do_run "$opt_pre_snapshot $ii $NAME"
|
||||||
if do_run "zfs snapshot $PROPS $FLAGS '$ii@$NAME'"
|
if do_run "zfs snapshot $PROPS $FLAGS '$ii@$NAME'"
|
||||||
then
|
then
|
||||||
|
do_run "$opt_post_snapshot $ii $NAME"
|
||||||
SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
|
SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
|
||||||
else
|
else
|
||||||
WARNING_COUNT=$(( $WARNING_COUNT + 1 ))
|
WARNING_COUNT=$(( $WARNING_COUNT + 1 ))
|
||||||
@ -198,6 +202,7 @@ GETOPT=$(getopt \
|
|||||||
--longoptions=default-exclude,dry-run,fast,skip-scrub,recursive \
|
--longoptions=default-exclude,dry-run,fast,skip-scrub,recursive \
|
||||||
--longoptions=event:,keep:,label:,prefix:,sep: \
|
--longoptions=event:,keep:,label:,prefix:,sep: \
|
||||||
--longoptions=debug,help,quiet,syslog,verbose \
|
--longoptions=debug,help,quiet,syslog,verbose \
|
||||||
|
--longoptions=pre-snapshot:,post-snapshot: \
|
||||||
--options=dnshe:l:k:p:rs:qgv \
|
--options=dnshe:l:k:p:rs:qgv \
|
||||||
-- "$@" ) \
|
-- "$@" ) \
|
||||||
|| exit 128
|
|| exit 128
|
||||||
@ -308,6 +313,14 @@ do
|
|||||||
opt_verbose='1'
|
opt_verbose='1'
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
(--pre-snapshot)
|
||||||
|
opt_pre_snapshot="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
(--post-snapshot)
|
||||||
|
opt_post_snapshot="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
(--)
|
(--)
|
||||||
shift 1
|
shift 1
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user