@@ -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_recv_opts=' '
4241opt_send_ssh_opts=' '
@@ -188,7 +187,7 @@ do_snapshots () # properties, flags, snapname, oldglob, [targets...]
188187 if [ $RUNSNAP -eq 1 ] && do_run " zfs snapshot $PROPS $FLAGS '$ii @$NAME '"
189188 then
190189 [ " $opt_post_snapshot " != " " ] && do_run " $opt_post_snapshot $ii $NAME "
191- [ -n " $opt_send_host " ] && SNAPS_DONE=" $SNAPS_DONE
190+ [ -n " $opt_send " ] && SNAPS_DONE=" $SNAPS_DONE
192191$ii @$NAME "
193192 SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
194193 else
@@ -228,13 +227,13 @@ do_send () # snapname, oldglob
228227 local NAME=" $1 "
229228 local GLOB=" $2 "
230229 local RUNSEND=1
231- local remote
230+ local remote_ssh=" ssh $opt_send_ssh_opts "
231+ local remote_recv=" zfs receive $opt_recv_opts "
232+ local remote_mbuf=" "
232233 local ii
233234 local jj
234235
235- [ -n " $opt_send_mbuf_opts " ] && remote=" mbuffer $opt_send_mbuf_opts |"
236- remote=" $remote ssh $opt_send_ssh_opts $opt_send_host "
237- remote=" $remote zfs receive $opt_recv_opts "
236+ [ -n " $opt_send_mbuf_opts " ] && remote_mbuf=" mbuffer $opt_send_mbuf_opts |"
238237
239238 # STEP 1: Go throug all snapshots we've created
240239 for ii in $SNAPS_DONE
@@ -309,17 +308,34 @@ $jj"
309308 fi
310309
311310 if [ $RUNSEND -eq 1 ]; then
312- if [ " $opt_send_type " = " incr" ]; then
313- if [ " $jj " = " $ii " -a -n " $opt_send_fallback " ]; then
314- do_run " zfs send $opt_send_opts -R $ii | $remote -F $opt_recv_pool " \
315- || RUNSEND=0
311+ OLD_IFS=$IFS ; IFS=" ;"
312+
313+ # Go through each option to --send-{incr,full}.
314+ # rem=<remote_host>:<remote_pool>
315+ for rem in $opt_send ; do
316+ if [ " $opt_send_type " = " incr" ]; then
317+ if [ " $jj " = " $ii " -a -n " $opt_send_fallback " ]; then
318+ cmd=" zfs send $opt_send_opts -R $ii |"
319+ cmd=" $cmd $remote_mbuf "
320+ cmd=" $cmd $remote_ssh ${rem%:* } "
321+ cmd=" $cmd $remote_recv -F ${rem#*: } "
322+ else
323+ cmd=" zfs send $opt_send_opts -i $jj $ii |"
324+ cmd=" $cmd $remote_mbuf "
325+ cmd=" $cmd $remote_ssh ${rem%:* } "
326+ cmd=" $cmd $remote_recv ${rem#*: } "
327+ fi
316328 else
317- do_run " zfs send $opt_send_opts -i $jj $ii | $remote $opt_recv_pool " \
318- || RUNSEND=0
329+ cmd=" zfs send $opt_send_opts -R $jj |"
330+ cmd=" $cmd $remote_mbuf "
331+ cmd=" $cmd $remote_ssh ${rem%:* } "
332+ cmd=" $cmd $remote_recv ${rem#*: } "
319333 fi
320- else
321- do_run " zfs send $opt_send_opts -R $jj | $remote $opt_recv_pool " || RUNSEND=0
322- fi
334+
335+ do_run " $cmd " || RUNSEND=0
336+ done
337+
338+ IFS=$OLD_IFS
323339
324340 if [ $RUNSEND = 1 -a -n " $opt_post_send " ]; then
325341 do_run " $opt_post_send $jj " || RUNSEND=0
426442 ;;
427443 (--send-full)
428444 opt_send_type=' full'
429-
430- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
431- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
432-
433445 opt_send_opts=" $opt_send_opts -R"
446+ opt_send=" $2 "
434447 shift 2
435448 ;;
436449 (--send-incr)
437450 opt_send_type=' incr'
438-
439- opt_send_host=$( echo " $2 " | sed ' s,:.*,,' )
440- opt_recv_pool=$( echo " $2 " | sed ' s,.*:,,' )
451+ opt_send=" $2 "
441452 shift 2
442453 ;;
443454 (--send-fallback)
0 commit comments