borg: fix connection test when remote dir exists

When testing the connection via ssh forced command, if the remote path
is an empty directory (instead of nonexistent), the handler bails even
tough the connection is successful.

Co-authored-by: Emil Breiner <emil.breinr@krumedia.com>
This commit is contained in:
Jerome Charaoui 2021-01-08 23:35:21 -05:00
parent 69df0f16f6
commit fe8778618f

View File

@ -106,14 +106,13 @@ if [ "$host" != "localhost" ] && ([ "$testconnect" = "yes" ] || [ "${test}" -eq
teststr="borg list --show-rc -v $execstr_repository"
debug "$teststr"
output=`su -c "$teststr" 2>&1`
if echo "$output" | grep "terminating with success status" ; then
if echo "$output" | grep "terminating with success status" \
|| echo "$output" | grep "^\S\+ is not a valid repository." \
|| echo "$output" | grep "^Repository \S\+ does not exist."; then
debug "Connected to $host as $user successfully (forced command)"
else
if echo "$output" | grep -E "Repository.+does not exist" ; then
debug "Connected to $host as $user successfully (forced command)"
else
fatal "Can't connect to $host as $user."
fi
error $output
fatal "Can't connect to $host as $user."
fi
fi
fi