@@ -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=' '
@@ -258,7 +257,7 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
258
257
if [ $RUNSNAP -eq 1 ] && do_run " zfs snapshot $PROPS $FLAGS '$ii @$NAME '"
259
258
then
260
259
[ " $opt_post_snapshot " != " " ] && do_run " $opt_post_snapshot $ii $NAME "
261
- [ -n " $opt_send_host " ] && SNAPS_DONE=" $SNAPS_DONE
260
+ [ -n " $opt_send " ] && SNAPS_DONE=" $SNAPS_DONE
262
261
$ii @$NAME "
263
262
SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
264
263
else
@@ -304,13 +303,13 @@ do_send () # snapname, oldglob
304
303
local NAME=" $1 "
305
304
local GLOB=" $2 "
306
305
local RUNSEND=1
307
- local remote
306
+ local remote_ssh=" ssh $opt_send_ssh_opts "
307
+ local remote_recv=" zfs receive $opt_recv_opts "
308
+ local remote_mbuf=" "
308
309
local ii
309
310
local jj
310
311
311
- [ -n " $opt_send_mbuf_opts " ] && remote=" mbuffer $opt_send_mbuf_opts |"
312
- remote=" $remote ssh $opt_send_ssh_opts $opt_send_host "
313
- remote=" $remote zfs receive $opt_recv_opts "
312
+ [ -n " $opt_send_mbuf_opts " ] && remote_mbuf=" mbuffer $opt_send_mbuf_opts |"
314
313
315
314
# STEP 1: Go throug all snapshots we've created
316
315
for ii in $SNAPS_DONE
@@ -329,17 +328,34 @@ do_send () # snapname, oldglob
329
328
fi
330
329
331
330
if [ $RUNSEND -eq 1 ]; then
332
- if [ " $opt_send_type " = " incr" ]; then
333
- if [ " $jj " = " $ii " -a -n " $opt_send_fallback " ]; then
334
- do_run " zfs send $opt_send_opts -R $ii | $remote -F $opt_recv_pool " \
335
- || RUNSEND=0
331
+ OLD_IFS=$IFS ; IFS=" ;"
332
+
333
+ # Go through each option to --send-{incr,full}.
334
+ # rem=<remote_host>:<remote_pool>
335
+ for rem in $opt_send ; do
336
+ if [ " $opt_send_type " = " incr" ]; then
337
+ if [ " $jj " = " $ii " -a -n " $opt_send_fallback " ]; then
338
+ cmd=" zfs send $opt_send_opts -R $ii |"
339
+ cmd=" $cmd $remote_mbuf "
340
+ cmd=" $cmd $remote_ssh ${rem%:* } "
341
+ cmd=" $cmd $remote_recv -F ${rem#*: } "
342
+ else
343
+ cmd=" zfs send $opt_send_opts -i $jj $ii |"
344
+ cmd=" $cmd $remote_mbuf "
345
+ cmd=" $cmd $remote_ssh ${rem%:* } "
346
+ cmd=" $cmd $remote_recv ${rem#*: } "
347
+ fi
336
348
else
337
- do_run " zfs send $opt_send_opts -i $jj $ii | $remote $opt_recv_pool " \
338
- || RUNSEND=0
349
+ cmd=" zfs send $opt_send_opts -R $jj |"
350
+ cmd=" $cmd $remote_mbuf "
351
+ cmd=" $cmd $remote_ssh ${rem%:* } "
352
+ cmd=" $cmd $remote_recv ${rem#*: } "
339
353
fi
340
- else
341
- do_run " zfs send $opt_send_opts -R $jj | $remote $opt_recv_pool " || RUNSEND=0
342
- fi
354
+
355
+ do_run " $cmd " || RUNSEND=0
356
+ done
357
+
358
+ IFS=$OLD_IFS
343
359
344
360
if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
345
361
do_run " $opt_post_send $jj " || RUNSEND=0
446
462
;;
447
463
(--send-full)
448
464
opt_send_type=' full'
449
-
450
- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
451
- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
452
-
453
465
opt_send_opts=" $opt_send_opts -R"
466
+ opt_send=" $2 "
454
467
shift 2
455
468
;;
456
469
(--send-incr)
457
470
opt_send_type=' incr'
458
-
459
- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
460
- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
471
+ opt_send=" $2 "
461
472
shift 2
462
473
;;
463
474
(--send-fallback)
0 commit comments