@@ -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.
@@ -218,6 +220,7 @@ do_send () # snapname, oldglob
218220{
219221 local NAME=" $1 "
220222 local GLOB=" $2 "
223+ local RUNSEND=1
221224 local remote=" ssh $opt_send_host zfs receive $opt_recv_opts $opt_recv_pool "
222225 local ii
223226 local jj
@@ -279,11 +282,22 @@ $jj"
279282 # STEP 4: Go through all snapshots that is to be transfered and send them.
280283 for jj in $SNAPS_SEND
281284 do
282- if [ " $opt_send_type " = " incr" ]; then
283- do_run " zfs send $opt_send_opts -i $jj $ii | $remote "
284- else
285- do_run " zfs send $opt_send_opts -R $jj | $remote "
285+ if [ -n " $opt_pre_send " ]; then
286+ do_run " $opt_pre_send $jj " || RUNSEND=0
287+ fi
288+
289+ if [ $RUNSEND -eq 1 ]; then
290+ if [ " $opt_send_type " = " incr" ]; then
291+ do_run " zfs send $opt_send_opts -i $jj $ii | $remote " || RUNSEND=0
292+ else
293+ do_run " zfs send $opt_send_opts -R $jj | $remote " || RUNSEND=0
294+ fi
295+ fi
296+
297+ if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
298+ do_run " $opt_post_send $jj " || RUNSEND=0
286299 fi
300+
287301 done
288302 done
289303}
@@ -297,6 +311,7 @@ GETOPT=$(getopt \
297311 --longoptions=debug,help,quiet,syslog,verbose \
298312 --longoptions=pre-snapshot:,post-snapshot:,destroy-only \
299313 --longoptions=send-full:,send-incr:,send-opts:,recv-opts: \
314+ --longoptions=pre-send:,post-send: \
300315 --options=dnshe:l:k:p:rs:qgv \
301316 -- " $@ " ) \
302317 || exit 128
439454 opt_post_snapshot=" $2 "
440455 shift 2
441456 ;;
457+ (--pre-send)
458+ opt_pre_send=" $2 "
459+ shift 2
460+ ;;
461+ (--post-send)
462+ opt_post_send=" $2 "
463+ shift 2
464+ ;;
442465 (--destroy-only)
443466 opt_do_snapshots=' '
444467 shift 1
0 commit comments