@@ -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.
@@ -275,6 +277,7 @@ do_send () # snapname, oldglob
275277{
276278 local NAME=" $1 "
277279 local GLOB=" $2 "
280+ local RUNSEND=1
278281 local remote=" ssh $opt_send_host zfs receive $opt_recv_opts $opt_recv_pool "
279282 local ii
280283 local jj
@@ -291,10 +294,20 @@ do_send () # snapname, oldglob
291294 # STEP 3: Go through all snapshots that is to be transfered and send them.
292295 for jj in $SNAPS_SEND
293296 do
294- if [ " $opt_send_type " = " incr" ]; then
295- do_run " zfs send $opt_send_opts -i $jj $ii | $remote "
296- else
297- do_run " zfs send $opt_send_opts -R $jj | $remote "
297+ if [ -n " $opt_pre_send " ]; then
298+ do_run " $opt_pre_send $jj " || RUNSEND=0
299+ fi
300+
301+ if [ $RUNSEND -eq 1 ]; then
302+ if [ " $opt_send_type " = " incr" ]; then
303+ do_run " zfs send $opt_send_opts -i $jj $ii | $remote " || RUNSEND=0
304+ else
305+ do_run " zfs send $opt_send_opts -R $jj | $remote " || RUNSEND=0
306+ fi
307+
308+ if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
309+ do_run " $opt_post_send $jj " || RUNSEND=0
310+ fi
298311 fi
299312 done
300313 done
@@ -309,6 +322,7 @@ GETOPT=$(getopt \
309322 --longoptions=debug,help,quiet,syslog,verbose \
310323 --longoptions=pre-snapshot:,post-snapshot:,destroy-only \
311324 --longoptions=send-full:,send-incr:,send-opts:,recv-opts: \
325+ --longoptions=pre-send:,post-send: \
312326 --options=dnshe:l:k:p:rs:qgv \
313327 -- " $@ " ) \
314328 || exit 128
451465 opt_post_snapshot=" $2 "
452466 shift 2
453467 ;;
468+ (--pre-send)
469+ opt_pre_send=" $2 "
470+ shift 2
471+ ;;
472+ (--post-send)
473+ opt_post_send=" $2 "
474+ shift 2
475+ ;;
454476 (--destroy-only)
455477 opt_do_snapshots=' '
456478 shift 1
0 commit comments