@@ -35,8 +35,7 @@ opt_label=''
3535opt_prefix=' zfs-auto-snap'
3636opt_recursive=' '
3737opt_send_type=' '
38- opt_send_host=' '
39- opt_recv_pool=' '
38+ opt_send=' '
4039opt_send_opts=' '
4140opt_send_only=' '
4241opt_recv_opts=' '
@@ -258,7 +257,7 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
258257 if [ $RUNSNAP -eq 1 ] && do_run " zfs snapshot $PROPS $FLAGS '$ii @$NAME '"
259258 then
260259 [ " $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
262261$ii @$NAME "
263262 SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
264263 else
@@ -304,13 +303,13 @@ do_send () # snapname, oldglob
304303 local NAME=" $1 "
305304 local GLOB=" $2 "
306305 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=" "
308309 local ii
309310 local jj
310311
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 |"
314313
315314 # STEP 1: Go throug all snapshots we've created
316315 for ii in $SNAPS_DONE
@@ -329,17 +328,34 @@ do_send () # snapname, oldglob
329328 fi
330329
331330 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
336348 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#*: } "
339353 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
343359
344360 if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
345361 do_run " $opt_post_send $jj " || RUNSEND=0
446462 ;;
447463 (--send-full)
448464 opt_send_type=' full'
449-
450- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
451- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
452-
453465 opt_send_opts=" $opt_send_opts -R"
466+ opt_send=" $2 "
454467 shift 2
455468 ;;
456469 (--send-incr)
457470 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 "
461472 shift 2
462473 ;;
463474 (--send-fallback)
0 commit comments