Skip to content
Permalink
Browse files

ftp host on custom port

  • Loading branch information...
serghey-rodin committed Apr 5, 2013
1 parent 4f7959b commit 5d040c444717c31f8b7178cbafe3ba1c1a8c0b35
Showing with 14 additions and 6 deletions.
  1. +5 −3 bin/v-add-backup-ftp-host
  2. +8 −2 bin/v-backup-user
  3. +1 −1 bin/v-list-backup-ftp-host
@@ -1,6 +1,6 @@
#!/bin/bash
# info: add backup ftp host
# options: HOST USERNAME PASSWORD [PATH]
# options: HOST USERNAME PASSWORD [PATH] [PORT]
#
# The function adds ftp host for system backups

@@ -14,6 +14,7 @@ host=$1
ftp_user=$2
ftp_password=$3
ftp_path=${4-/backup}
ftp_port=${5-21}
A3='******'

# Includes
@@ -22,7 +23,7 @@ source $VESTA/func/main.sh

# Defining ftp command function
ftpc() {
ftp -n $host <<EOF
ftp -n $host $ftp_port <<EOF
quote USER $ftp_user
quote PASS $ftp_password
binary
@@ -38,7 +39,7 @@ EOF
# Verifications #
#----------------------------------------------------------#

check_args '3' "$#" "HOST USERNAME PASSWORD [PATH]"
check_args '3' "$#" "HOST USERNAME PASSWORD [PATH] [PORT]"
validate_format 'host' 'ftp_user' 'ftp_password'


@@ -69,6 +70,7 @@ echo "HOST='$host'
USERNAME='$ftp_user'
PASSWORD='$ftp_password'
BPATH='$ftp_path'
PORT='$ftp_port'
TIME='$TIME'
DATE='$DATE'" > $VESTA/conf/ftp.backup.conf
chmod 660 $VESTA/conf/ftp.backup.conf
@@ -515,7 +515,7 @@ local_backup(){

# Defining ftp command function
ftpc() {
ftp -n $HOST <<EOF
ftp -n $HOST $PORT <<EOF
quote USER $USERNAME
quote PASS $PASSWORD
binary
@@ -541,6 +541,11 @@ ftp_backup() {
# Parse config
source $VESTA/conf/ftp.backup.conf

# Set default port
if [ -z "$(grep 'PORT=' $VESTA/conf/ftp.backup.conf)" ]; then
PORT='21'
fi

# Checking variables
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
rm -rf $tmpdir
@@ -552,6 +557,7 @@ ftp_backup() {
exit $E_PARSING
fi


# Debug info
echo -e "$(date "+%F %T") FTP ftp://$HOST$BPATH/$user.$DATE.tar"

@@ -560,7 +566,7 @@ ftp_backup() {
rm -rf $tmpdir
echo "Can't login to ftp://$USERNAME@$HOST" |\
$send_mail -s "$subj" $email
echo "Error: can't login to ftp"
echo "Error: can't login to ftp ftp://$USERNAME@$HOST"
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_FTP" "$EVENT"
exit $E_FTP
@@ -69,7 +69,7 @@ if [ ! -e "$VESTA/conf/ftp.backup.conf" ]; then
fi

# Defining fileds to select
fields='$HOST $USERNAME $TIME $DATE'
fields='$HOST $USERNAME $PORT $TIME $DATE'

# Listing database
case $format in

0 comments on commit 5d040c4

Please sign in to comment.
You can’t perform that action at this time.