@@ -36,8 +36,7 @@ opt_label=''
36
36
opt_prefix=' zfs-auto-snap'
37
37
opt_recursive=' '
38
38
opt_send_type=' '
39
- opt_send_host=' '
40
- opt_recv_pool=' '
39
+ opt_send=' '
41
40
opt_send_opts=' '
42
41
opt_recv_opts=' '
43
42
opt_send_ssh_opts=' '
@@ -229,7 +228,7 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
229
228
if [ $RUNSNAP -eq 1 ] && do_run " zfs snapshot $PROPS $FLAGS '$ii @$NAME '"
230
229
then
231
230
[ " $opt_post_snapshot " != " " ] && do_run " $opt_post_snapshot $ii $NAME "
232
- [ -n " $opt_send_host " ] && SNAPS_DONE=" $SNAPS_DONE
231
+ [ -n " $opt_send " ] && SNAPS_DONE=" $SNAPS_DONE
233
232
$ii @$NAME "
234
233
SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
235
234
else
@@ -269,13 +268,13 @@ do_send () # snapname, oldglob
269
268
local NAME=" $1 "
270
269
local GLOB=" $2 "
271
270
local RUNSEND=1
272
- local remote
271
+ local remote_ssh=" ssh $opt_send_ssh_opts "
272
+ local remote_recv=" zfs receive $opt_recv_opts "
273
+ local remote_mbuf=" "
273
274
local ii
274
275
local jj
275
276
276
- [ -n " $opt_send_mbuf_opts " ] && remote=" mbuffer $opt_send_mbuf_opts |"
277
- remote=" $remote ssh $opt_send_ssh_opts $opt_send_host "
278
- remote=" $remote zfs receive $opt_recv_opts "
277
+ [ -n " $opt_send_mbuf_opts " ] && remote_mbuf=" mbuffer $opt_send_mbuf_opts |"
279
278
280
279
# STEP 1: Go throug all snapshots we've created
281
280
for ii in $SNAPS_DONE
@@ -350,17 +349,34 @@ $jj"
350
349
fi
351
350
352
351
if [ $RUNSEND -eq 1 ]; then
353
- if [ " $opt_send_type " = " incr" ]; then
354
- if [ " $jj " = " $ii " -a -n " $opt_send_fallback " ]; then
355
- do_run " zfs send $opt_send_opts -R $ii | $remote -F $opt_recv_pool " \
356
- || RUNSEND=0
352
+ OLD_IFS=$IFS ; IFS=" ;"
353
+
354
+ # Go through each option to --send-{incr,full}.
355
+ # rem=<remote_host>:<remote_pool>
356
+ for rem in $opt_send ; do
357
+ if [ " $opt_send_type " = " incr" ]; then
358
+ if [ " $jj " = " $ii " -a -n " $opt_send_fallback " ]; then
359
+ cmd=" zfs send $opt_send_opts -R $ii |"
360
+ cmd=" $cmd $remote_mbuf "
361
+ cmd=" $cmd $remote_ssh ${rem%:* } "
362
+ cmd=" $cmd $remote_recv -F ${rem#*: } "
363
+ else
364
+ cmd=" zfs send $opt_send_opts -i $jj $ii |"
365
+ cmd=" $cmd $remote_mbuf "
366
+ cmd=" $cmd $remote_ssh ${rem%:* } "
367
+ cmd=" $cmd $remote_recv ${rem#*: } "
368
+ fi
357
369
else
358
- do_run " zfs send $opt_send_opts -i $jj $ii | $remote $opt_recv_pool " \
359
- || RUNSEND=0
370
+ cmd=" zfs send $opt_send_opts -R $jj |"
371
+ cmd=" $cmd $remote_mbuf "
372
+ cmd=" $cmd $remote_ssh ${rem%:* } "
373
+ cmd=" $cmd $remote_recv ${rem#*: } "
360
374
fi
361
- else
362
- do_run " zfs send $opt_send_opts -R $jj | $remote $opt_recv_pool " || RUNSEND=0
363
- fi
375
+
376
+ do_run " $cmd " || RUNSEND=0
377
+ done
378
+
379
+ IFS=$OLD_IFS
364
380
365
381
if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
366
382
do_run " $opt_post_send $jj " || RUNSEND=0
471
487
;;
472
488
(--send-full)
473
489
opt_send_type=' full'
474
-
475
- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
476
- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
477
-
478
490
opt_send_opts=" $opt_send_opts -R"
491
+ opt_send=" $2 "
479
492
shift 2
480
493
;;
481
494
(--send-incr)
482
495
opt_send_type=' incr'
483
-
484
- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
485
- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
496
+ opt_send=" $2 "
486
497
shift 2
487
498
;;
488
499
(--send-fallback)
0 commit comments