@@ -35,8 +35,7 @@ opt_label=''
35
35
opt_prefix=' zfs-auto-snap'
36
36
opt_recursive=' '
37
37
opt_send_type=' '
38
- opt_send_host=' '
39
- opt_recv_pool=' '
38
+ opt_send=' '
40
39
opt_send_opts=' '
41
40
opt_send_only=' '
42
41
opt_recv_opts=' '
@@ -189,7 +188,7 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
189
188
if [ $RUNSNAP -eq 1 ] && do_run " zfs snapshot $PROPS $FLAGS '$ii @$NAME '"
190
189
then
191
190
[ " $opt_post_snapshot " != " " ] && do_run " $opt_post_snapshot $ii $NAME "
192
- [ -n " $opt_send_host " ] && SNAPS_DONE=" $SNAPS_DONE
191
+ [ -n " $opt_send " ] && SNAPS_DONE=" $SNAPS_DONE
193
192
$ii @$NAME "
194
193
SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
195
194
else
@@ -244,13 +243,13 @@ do_send () # snapname, oldglob
244
243
local NAME=" $1 "
245
244
local GLOB=" $2 "
246
245
local RUNSEND=1
247
- local remote
246
+ local remote_ssh=" ssh $opt_send_ssh_opts "
247
+ local remote_recv=" zfs receive $opt_recv_opts "
248
+ local remote_mbuf=" "
248
249
local ii
249
250
local jj
250
251
251
- [ -n " $opt_send_mbuf_opts " ] && remote=" mbuffer $opt_send_mbuf_opts |"
252
- remote=" $remote ssh $opt_send_ssh_opts $opt_send_host "
253
- remote=" $remote zfs receive $opt_recv_opts "
252
+ [ -n " $opt_send_mbuf_opts " ] && remote_mbuf=" mbuffer $opt_send_mbuf_opts |"
254
253
255
254
# STEP 1: Go throug all snapshots we've created
256
255
for ii in $SNAPS_DONE
@@ -325,17 +324,34 @@ $jj"
325
324
fi
326
325
327
326
if [ $RUNSEND -eq 1 ]; then
328
- if [ " $opt_send_type " = " incr" ]; then
329
- if [ " $jj " = " $ii " -a -n " $opt_send_fallback " ]; then
330
- do_run " zfs send $opt_send_opts -R $ii | $remote -F $opt_recv_pool " \
331
- || RUNSEND=0
327
+ OLD_IFS=$IFS ; IFS=" ;"
328
+
329
+ # Go through each option to --send-{incr,full}.
330
+ # rem=<remote_host>:<remote_pool>
331
+ for rem in $opt_send ; do
332
+ if [ " $opt_send_type " = " incr" ]; then
333
+ if [ " $jj " = " $ii " -a -n " $opt_send_fallback " ]; then
334
+ cmd=" zfs send $opt_send_opts -R $ii |"
335
+ cmd=" $cmd $remote_mbuf "
336
+ cmd=" $cmd $remote_ssh ${rem%:* } "
337
+ cmd=" $cmd $remote_recv -F ${rem#*: } "
338
+ else
339
+ cmd=" zfs send $opt_send_opts -i $jj $ii |"
340
+ cmd=" $cmd $remote_mbuf "
341
+ cmd=" $cmd $remote_ssh ${rem%:* } "
342
+ cmd=" $cmd $remote_recv ${rem#*: } "
343
+ fi
332
344
else
333
- do_run " zfs send $opt_send_opts -i $jj $ii | $remote $opt_recv_pool " \
334
- || RUNSEND=0
345
+ cmd=" zfs send $opt_send_opts -R $jj |"
346
+ cmd=" $cmd $remote_mbuf "
347
+ cmd=" $cmd $remote_ssh ${rem%:* } "
348
+ cmd=" $cmd $remote_recv ${rem#*: } "
335
349
fi
336
- else
337
- do_run " zfs send $opt_send_opts -R $jj | $remote $opt_recv_pool " || RUNSEND=0
338
- fi
350
+
351
+ do_run " $cmd " || RUNSEND=0
352
+ done
353
+
354
+ IFS=$OLD_IFS
339
355
340
356
if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
341
357
do_run " $opt_post_send $jj " || RUNSEND=0
442
458
;;
443
459
(--send-full)
444
460
opt_send_type=' full'
445
-
446
- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
447
- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
448
-
449
461
opt_send_opts=" $opt_send_opts -R"
462
+ opt_send=" $2 "
450
463
shift 2
451
464
;;
452
465
(--send-incr)
453
466
opt_send_type=' incr'
454
-
455
- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
456
- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
467
+ opt_send=" $2 "
457
468
shift 2
458
469
;;
459
470
(--send-fallback)
0 commit comments