From b57c4dcd7b7559bae4131bae6bba9a64f34b98e7 Mon Sep 17 00:00:00 2001 From: dpeca Date: Thu, 4 May 2017 19:11:34 +0200 Subject: [PATCH] Allow v-restore-user to restore backup from FTP and SFTP Before this fix, sftpc() function had two 'else' blocks... so it was broken code... and script was unable to download file from SFTP --- bin/v-restore-user | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/v-restore-user b/bin/v-restore-user index 750ae421..90aff163 100755 --- a/bin/v-restore-user +++ b/bin/v-restore-user @@ -62,7 +62,11 @@ ftp_download() { if [ -z "$PORT" ]; then PORT='21' fi - ftpc "cd $BPATH" "get $1" + if [ -z $BPATH ]; then + ftpc "get $1" + else + ftpc "cd $BPATH" "get $1" + fi } # sftp command function @@ -99,8 +103,6 @@ sftpc() { set arg [lindex \$argv \$count] send "\$arg\r" incr count - } else { - incr count } else { send "exit\r" set output "Disconnected." @@ -131,7 +133,11 @@ sftp_download() { PORT='22' fi cd $BACKUP - sftpc "cd $BPATH" "get $1" > /dev/null 2>&1 + if [ -z $BPATH ]; then + sftpc "get $1" > /dev/null 2>&1 + else + sftpc "cd $BPATH" "get $1" > /dev/null 2>&1 + fi }