@@ -46,6 +46,8 @@ opt_skip_scrub=''
4646opt_verbose=' '
4747opt_pre_snapshot=' '
4848opt_post_snapshot=' '
49+ opt_pre_send=' '
50+ opt_post_send=' '
4951opt_do_snapshots=1
5052
5153# Global summary statistics.
@@ -217,6 +219,7 @@ do_send () # snapname, oldglob
217219{
218220 local NAME=" $1 "
219221 local GLOB=" $2 "
222+ local RUNSEND=1
220223 local remote=" ssh $opt_send_host zfs receive $opt_recv_opts $opt_recv_pool "
221224 local ii
222225 local jj
@@ -278,10 +281,20 @@ $jj"
278281 # STEP 4: Go through all snapshots that is to be transfered and send them.
279282 for jj in $SNAPS_SEND
280283 do
281- if [ " $opt_send_type " = " incr" ]; then
282- do_run " zfs send $opt_send_opts -i $jj $ii | $remote "
283- else
284- do_run " zfs send $opt_send_opts -R $jj | $remote "
284+ if [ -n " $opt_pre_send " ]; then
285+ do_run " $opt_pre_send $jj " || RUNSEND=0
286+ fi
287+
288+ if [ $RUNSEND -eq 1 ]; then
289+ if [ " $opt_send_type " = " incr" ]; then
290+ do_run " zfs send $opt_send_opts -i $jj $ii | $remote " || RUNSEND=0
291+ else
292+ do_run " zfs send $opt_send_opts -R $jj | $remote " || RUNSEND=0
293+ fi
294+
295+ if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
296+ do_run " $opt_post_send $jj " || RUNSEND=0
297+ fi
285298 fi
286299 done
287300 done
@@ -296,6 +309,7 @@ GETOPT=$(getopt \
296309 --longoptions=debug,help,quiet,syslog,verbose \
297310 --longoptions=pre-snapshot:,post-snapshot:,destroy-only \
298311 --longoptions=send-full:,send-incr:,send-opts:,recv-opts: \
312+ --longoptions=pre-send:,post-send: \
299313 --options=dnshe:l:k:p:rs:qgv \
300314 -- " $@ " ) \
301315 || exit 128
438452 opt_post_snapshot=" $2 "
439453 shift 2
440454 ;;
455+ (--pre-send)
456+ opt_pre_send=" $2 "
457+ shift 2
458+ ;;
459+ (--post-send)
460+ opt_post_send=" $2 "
461+ shift 2
462+ ;;
441463 (--destroy-only)
442464 opt_do_snapshots=' '
443465 shift 1
0 commit comments