chiark / gitweb /
rsync-backup.{in,8}: New option to set the remote user name.
authorMark Wooding <mwooding@good.com>
Mon, 15 Jul 2013 13:16:14 +0000 (14:16 +0100)
committerMark Wooding <mwooding@good.com>
Mon, 15 Jul 2013 17:23:51 +0000 (18:23 +0100)
The default is still to use no user name.

rsync-backup.8
rsync-backup.in

index 714b63fc99e4088e236d995e0bfe7400ffed755a..053a4c3ae8d038fc5827bd400583f72d55b5e106 100644 (file)
@@ -158,7 +158,9 @@ will avoid inefficient and pointless messing about
 in this case.
 This command clears the
 .B like
 in this case.
 This command clears the
 .B like
-list, and resets the retention policy to its default (i.e., the to
+list, the remote
+.B user
+name, and resets the retention policy to its default (i.e., the to
 policy defined prior to the first
 .B host
 command).
 policy defined prior to the first
 .B host
 command).
@@ -251,6 +253,15 @@ for subsequent backups.  Some snapshot types require additional
 arguments, which may be supplied here.  This command clears the
 .B retry
 counter.
 arguments, which may be supplied here.  This command clears the
 .B retry
 counter.
+.TP
+.BI "user " name
+Specify the user name on the remote host.  Without this, calls to
+.BR ssh (1)
+and
+.BR rsync (1)
+won't specify any user name, so the default (probably from the
+.BR ssh_config (5)
+file) will apply.
 .SS Configuration variables
 The following shell variables may be overridden by the configuration
 file.
 .SS Configuration variables
 The following shell variables may be overridden by the configuration
 file.
index 3802efb11186ebb30c584f74944b2de4ec321399..39b09d1571a7f19cf504fb63db4cea475fc7db7e 100644 (file)
@@ -133,7 +133,7 @@ hostrun () {
   ## way it will be processed by a shell.
 
   if localp $host; then run "@$host: $tag" sh -c "$cmd"
   ## way it will be processed by a shell.
 
   if localp $host; then run "@$host: $tag" sh -c "$cmd"
-  else run "@$host: $tag" ssh $host "$cmd"
+  else run "@$host: $tag" ssh $userat$host "$cmd"
   fi
 }
 
   fi
 }
 
@@ -153,7 +153,7 @@ hostpath () {
   ## current host is local.
 
   if localp $host; then echo $path
   ## current host is local.
 
   if localp $host; then echo $path
-  else echo $host:$path
+  else echo $userat$host:$path
   fi
 }
 
   fi
 }
 
@@ -310,7 +310,7 @@ do_rfreezefs () {
 
     ## Get the volume host to create the snapshot.
     set +e
 
     ## Get the volume host to create the snapshot.
     set +e
-    _hostrun >&2 3>&- $lvhost \
+    _hostrun >&2 3>&- $userat$lvhost \
       "lvcreate --snapshot -n$lv.bkp $SNAPSIZE $vg/$lv"
     snaprc=$?
     set -e
       "lvcreate --snapshot -n$lv.bkp $SNAPSIZE $vg/$lv"
     snaprc=$?
     set -e
@@ -321,7 +321,7 @@ do_rfreezefs () {
     case $tok in
       "$tok_THAWED") ;;
       *)
     case $tok in
       "$tok_THAWED") ;;
       *)
-       _hostrun >&2 3>&- $lvhost "lvremove -f $vg/$lv.bkp" || :
+       _hostrun >&2 3>&- $userat$lvhost "lvremove -f $vg/$lv.bkp" || :
        echo >&2 "$quis: unexpected token $tok (rfreezefs $fsdir on $fshost)"
        exit 1
        ;;
        echo >&2 "$quis: unexpected token $tok (rfreezefs $fsdir on $fshost)"
        exit 1
        ;;
@@ -348,7 +348,7 @@ do_rfreezefs () {
   esac
 
   ## Mount the snapshot on the volume host.
   esac
 
   ## Mount the snapshot on the volume host.
-  _hostrun >&2 $lvhost "
+  _hostrun >&2 $userat$lvhost "
        mkdir -p $SNAPDIR/$lv
        mount -oro /dev/$vg/$lv.bkp $SNAPDIR/$lv"
 }
        mkdir -p $SNAPDIR/$lv
        mount -oro /dev/$vg/$lv.bkp $SNAPDIR/$lv"
 }
@@ -525,7 +525,7 @@ unset VOLUME
 bkprc=0
 
 remote_fshash () {
 bkprc=0
 
 remote_fshash () {
-  _hostrun $host "
+  _hostrun $userat$host "
        umask 077
        mkdir -p $fshashdir
        cd ${snapmnt#*:}
        umask 077
        mkdir -p $fshashdir
        cd ${snapmnt#*:}
@@ -841,7 +841,7 @@ backup () {
 
 host () {
   host=$1
 
 host () {
   host=$1
-  like=
+  like= userat=
   case "${expire_policy+t},${default_policy+t}" in
     t,) default_policy=$expire_policy ;;
   esac
   case "${expire_policy+t},${default_policy+t}" in
     t,) default_policy=$expire_policy ;;
   esac
@@ -853,6 +853,7 @@ snaptype () { snap=$1; shift; snapargs="$*"; retry=0; }
 rsyncargs () { rsyncargs="$*"; }
 like () { like="$*"; }
 retry () { retry="$*"; }
 rsyncargs () { rsyncargs="$*"; }
 like () { like="$*"; }
 retry () { retry="$*"; }
+user () { userat="$*@"; }
 
 retain () {
   case $clear_policy in t) unset expire_policy; clear_policy=nil ;; esac
 
 retain () {
   case $clear_policy in t) unset expire_policy; clear_policy=nil ;; esac