Commit 80d544c4 authored by Fjen Undso's avatar Fjen Undso
Browse files

Merge branch 'sftp-keyfile' into 'master'

lftp: Use specific key file

See merge request !1
parents 6dfb4b19 c8e0b285
......@@ -39,6 +39,7 @@ declare -r FTP_HOST=""
declare -r FTP_USER=""
declare -r FTP_PASS="" # if empty, ssh key with no password is required
declare -r FTP_PORT="" # empty for default
declare -r FTP_KEYFILE="" # ssh key for sftp, empty for default
declare -r FTP_DIR=""
declare -r FTP_NUMBACKUPS=90
......@@ -239,11 +240,15 @@ encryption() {
}
exec_ftp() {
if [[ -n "$FTP_PORT" ]]; then
lftp -p $FTP_PORT -u $FTP_USER,$FTP_PASS $FTP_TYPE://$FTP_HOST -e "$1" 2> /dev/null
else
lftp -u $FTP_USER,$FTP_PASS $FTP_TYPE://$FTP_HOST -e "$1" 2> /dev/null
fi
local lftp_port
local lftp_con_prog
[[ -n "$FTP_PORT" ]] \
&& lftp_port="-p $FTP_PORT"
[[ -n "$FTP_KEYFILE" ]] \
&& lftp_con_prog="set sftp:connect-program \"ssh -a -x -i $FTP_KEYFILE\""
lftp -c "$lftp_con_prog; set net:max-retries 3; open $lftp_port -u $FTP_USER,$FTP_PASS $FTP_TYPE://$FTP_HOST; $1" 2> /dev/null
[[ $? -ne 0 ]] \
&& error "Failed to execute command on remote server: $1"
}
......@@ -251,7 +256,7 @@ exec_ftp() {
upload() {
if wants_upload; then
# FTP: directory creation
ftpmkdir=$(exec_ftp "mkdir -p \"$FTP_DIR/$date\"; exit")
exec_ftp "mkdir -p \"$FTP_DIR/$date\"; exit"
# FTP: delete old backups
info "Delete old backups on FTP..."
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment