@@ -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=' '
@@ -189,7 +188,7 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
189188 if [ $RUNSNAP -eq 1 ] && do_run " zfs snapshot $PROPS $FLAGS '$ii @$NAME '"
190189 then
191190 [ " $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
193192$ii @$NAME "
194193 SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
195194 else
@@ -244,13 +243,13 @@ do_send () # snapname, oldglob
244243 local NAME=" $1 "
245244 local GLOB=" $2 "
246245 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=" "
248249 local ii
249250 local jj
250251
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 |"
254253
255254 # STEP 1: Go throug all snapshots we've created
256255 for ii in $SNAPS_DONE
@@ -325,17 +324,34 @@ $jj"
325324 fi
326325
327326 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
332344 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#*: } "
335349 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
339355
340356 if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
341357 do_run " $opt_post_send $jj " || RUNSEND=0
442458 ;;
443459 (--send-full)
444460 opt_send_type=' full'
445-
446- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
447- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
448-
449461 opt_send_opts=" $opt_send_opts -R"
462+ opt_send=" $2 "
450463 shift 2
451464 ;;
452465 (--send-incr)
453466 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 "
457468 shift 2
458469 ;;
459470 (--send-fallback)
0 commit comments