rdiff: fix confusing error if rdiff-backup cannot be found on remote server.
[matthijs/upstream/backupninja.git] / handlers / rdiff.in
index 51da1cc8713becd43ee761939666e82a39d1646a..60386fac09987446c74d065c8de2cb5fec3053d4 100644 (file)
@@ -1,4 +1,5 @@
 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
+# vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
 #
 # rdiff-backup handler script for backupninja
 # requires rdiff-backup
@@ -30,6 +31,7 @@ function get_version() {
    # given no arguments, returns the local version.
    # given a user and host, returns the remote version.
    # if user or host is missing, returns the local version.
+   local version
    if [ "$#" -lt 2 ]; then
       debug "$RDIFFBACKUP -V"
       echo `$RDIFFBACKUP -V`
@@ -37,7 +39,12 @@ function get_version() {
       local user=$1
       local host=$2
       debug "ssh $sshoptions $host -l $user '$RDIFFBACKUP -V'"
-      echo `ssh $sshoptions $host -l $user "$RDIFFBACKUP -V | grep rdiff-backup"`
+      version=`ssh $sshoptions $host -l $user "$RDIFFBACKUP -V"`
+      if [ $? = 127 ]; then
+         fatal "Unable to execute rdiff-backup on remote server. It probably isn't installed"
+      else
+         echo "$version" | grep rdiff-backup
+      fi
    fi
 }
 
@@ -58,7 +65,7 @@ function check_consistency() {
       if [ "$user" == "" ]; then
          fatal "User must be specified for remote $section."
       fi
-      if [ "host" == "" ]; then
+      if [ "$host" == "" ]; then
          fatal "Host must be specifed for remote $section."
       fi
    fi
@@ -208,20 +215,28 @@ symlinks_warning="Maybe you have mixed symlinks and '*' in this statement, which
 
 # TODO: order the includes and excludes
 # excludes
+SAVEIFS=$IFS
+IFS=$(echo -en "\n\b")
 for i in $exclude; do
    str="${i//__star__/*}"
    execstr="${execstr}--exclude '$str' "
 done
+IFS=$SAVEIFS
 # includes
+SAVEIFS=$IFS
+IFS=$(echo -en "\n\b")
 for i in $include; do
    [ "$i" != "/" ] || fatal "Sorry, you cannot use 'include = /'"
    str="${i//__star__/*}"
    execstr="${execstr}--include '$str' "
 done
+IFS=$SAVEIFS
 
 # vsinclude
 if [ $usevserver = yes ]; then
    for vserver in $vsnames; do
+      SAVEIFS=$IFS
+      IFS=$(echo -en "\n\b")
       for vi in $vsinclude; do
          str="${vi//__star__/*}"
          str="$VROOTDIR/$vserver$str"
@@ -231,6 +246,7 @@ if [ $usevserver = yes ]; then
             warning "vsinclude statement '${vi//__star__/*}' will be ignored for VServer $vserver. $symlinks_warning"
          fi
       done
+      IFS=$SAVEIFS
    done
 fi