From fdd73e22e2baa4d70eaa65a1cd647ccacf42565e Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Mon, 15 Jul 2013 14:16:14 +0100 Subject: [PATCH 1/1] rsync-backup.{in,8}: New option to set the remote user name. Organization: Straylight/Edgeware From: Mark Wooding The default is still to use no user name. --- rsync-backup.8 | 13 ++++++++++++- rsync-backup.in | 15 ++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/rsync-backup.8 b/rsync-backup.8 index 714b63f..053a4c3 100644 --- a/rsync-backup.8 +++ b/rsync-backup.8 @@ -158,7 +158,9 @@ will avoid inefficient and pointless messing about 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). @@ -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. +.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. diff --git a/rsync-backup.in b/rsync-backup.in index 3802efb..39b09d1 100644 --- a/rsync-backup.in +++ b/rsync-backup.in @@ -133,7 +133,7 @@ hostrun () { ## 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 } @@ -153,7 +153,7 @@ hostpath () { ## current host is local. if localp $host; then echo $path - else echo $host:$path + else echo $userat$host:$path fi } @@ -310,7 +310,7 @@ do_rfreezefs () { ## 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 @@ -321,7 +321,7 @@ do_rfreezefs () { 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 ;; @@ -348,7 +348,7 @@ do_rfreezefs () { 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" } @@ -525,7 +525,7 @@ unset VOLUME bkprc=0 remote_fshash () { - _hostrun $host " + _hostrun $userat$host " umask 077 mkdir -p $fshashdir cd ${snapmnt#*:} @@ -841,7 +841,7 @@ backup () { host () { host=$1 - like= + like= userat= 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="$*"; } +user () { userat="$*@"; } retain () { case $clear_policy in t) unset expire_policy; clear_policy=nil ;; esac -- [mdw]