Skip to content

Commit b57c4dc

Browse files
authored
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
1 parent 4aeec46 commit b57c4dc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

bin/v-restore-user

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ ftp_download() {
6262
if [ -z "$PORT" ]; then
6363
PORT='21'
6464
fi
65-
ftpc "cd $BPATH" "get $1"
65+
if [ -z $BPATH ]; then
66+
ftpc "get $1"
67+
else
68+
ftpc "cd $BPATH" "get $1"
69+
fi
6670
}
6771

6872
# sftp command function
@@ -99,8 +103,6 @@ sftpc() {
99103
set arg [lindex \$argv \$count]
100104
send "\$arg\r"
101105
incr count
102-
} else {
103-
incr count
104106
} else {
105107
send "exit\r"
106108
set output "Disconnected."
@@ -131,7 +133,11 @@ sftp_download() {
131133
PORT='22'
132134
fi
133135
cd $BACKUP
134-
sftpc "cd $BPATH" "get $1" > /dev/null 2>&1
136+
if [ -z $BPATH ]; then
137+
sftpc "get $1" > /dev/null 2>&1
138+
else
139+
sftpc "cd $BPATH" "get $1" > /dev/null 2>&1
140+
fi
135141

136142
}
137143

0 commit comments

Comments
 (0)