@@ -46,6 +46,8 @@ opt_skip_scrub=''
46
46
opt_verbose=' '
47
47
opt_pre_snapshot=' '
48
48
opt_post_snapshot=' '
49
+ opt_pre_send=' '
50
+ opt_post_send=' '
49
51
opt_do_snapshots=1
50
52
51
53
# Global summary statistics.
@@ -220,6 +222,7 @@ do_send () # snapname, oldglob
220
222
local GLOB=" $2 "
221
223
local ii
222
224
local remote=" ssh $opt_send_host zfs receive $opt_recv_opts $opt_recv_pool "
225
+ local RUNSEND=1
223
226
224
227
# STEP 1: Go throug all snapshots we've created
225
228
for ii in $SNAPS_DONE
@@ -278,11 +281,22 @@ $jj"
278
281
# STEP 4: Go through all snapshots that is to be transfered and send them.
279
282
for jj in $SNAPS_SEND
280
283
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
+ fi
295
+
296
+ if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
297
+ do_run " $opt_post_send $jj " || RUNSEND=0
285
298
fi
299
+
286
300
done
287
301
done
288
302
}
@@ -296,6 +310,7 @@ GETOPT=$(getopt \
296
310
--longoptions=debug,help,quiet,syslog,verbose \
297
311
--longoptions=pre-snapshot:,post-snapshot:,destroy-only \
298
312
--longoptions=send-full:,send-incr:,send-opts:,recv-opts: \
313
+ --longoptions=pre-send:,post-send: \
299
314
--options=dnshe:l:k:p:rs:qgv \
300
315
-- " $@ " ) \
301
316
|| exit 128
438
453
opt_post_snapshot=" $2 "
439
454
shift 2
440
455
;;
456
+ (--pre-send)
457
+ opt_pre_send=" $2 "
458
+ shift 2
459
+ ;;
460
+ (--post-send)
461
+ opt_post_send=" $2 "
462
+ shift 2
463
+ ;;
441
464
(--destroy-only)
442
465
opt_do_snapshots=' '
443
466
shift 1
0 commit comments