Skip to content

Commit

Permalink
Fix for ftp backup on RHEL5 and Ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
serghey-rodin committed Oct 12, 2013
1 parent b531e9f commit 735067a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 5 additions & 4 deletions bin/v-add-backup-ftp-host
Expand Up @@ -23,7 +23,7 @@ source $VESTA/conf/vesta.conf

# Defining ftp command function
ftpc() {
ftp -n $host $ftp_port <<EOF
ftp -p -n $host $ftp_port <<EOF
quote USER $ftp_user
quote PASS $ftp_password
binary
Expand All @@ -48,16 +48,17 @@ validate_format 'host' 'ftp_user' 'ftp_password'
#----------------------------------------------------------#

# Checking network connection
ftp_connect=$(ftpc)
if [ ! -z "$(echo $ftp_connect |grep -i -e error -e 'not connected')" ]; then
fconn=$(ftpc)
ferror=$(echo $fconn |grep -i -e failed -e error -e "Can't" -e "not conn")
if [ ! -z "$ferror" ]; then
echo "Error: can't login to ftp"
log_event "$E_CONNECT" "$EVENT"
exit $E_CONNECT
fi

# Checking write permissions
ftpc "mkdir $ftp_path" > /dev/null 2>&1
ftmpdir=$(mktemp -u -p "$ftp_path")
ftmpdir="$ftp_path/vst.bK76A9SUkt"
ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir"|grep -v Trying)
if [ ! -z "$ftp_result" ] ; then
echo "$ftp_result"
Expand Down
10 changes: 6 additions & 4 deletions bin/v-backup-user
Expand Up @@ -509,7 +509,7 @@ local_backup(){

# Defining ftp command function
ftpc() {
/usr/bin/ftp -n $HOST $PORT <<EOF
/usr/bin/ftp -p -n $HOST $PORT <<EOF
quote USER $USERNAME
quote PASS $PASSWORD
binary
Expand Down Expand Up @@ -556,8 +556,9 @@ ftp_backup() {
echo -e "$(date "+%F %T") FTP ftp://$HOST$BPATH/$user.$DATE.tar"

# Checking ftp connection
ftp_connect=$(ftpc)
if [ ! -z "$(echo $ftp_connect |grep -i -e error -e 'not conn')" ]; then
fconn=$(ftpc)
ferror=$(echo $fconn |grep -i -e failed -e error -e "Can't" -e "not conn")
if [ ! -z "$ferror" ]; then
rm -rf $tmpdir
echo "Can't login to ftp://$USERNAME@$HOST" |\
$send_mail -s "$subj" $email
Expand All @@ -569,7 +570,8 @@ ftp_backup() {

# Check ftp permissions
ftpc "mkdir $BPATH" > /dev/null 2>&1
ftmpdir=$(mktemp -u -p "$BPATH")
ftmpdir="$BPATH/vst.bK76A9SUkt"
ftpc "mkdir $ftmpdir" "rm $ftmpdir"
ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir" |grep -v Trying)
if [ ! -z "$ftp_result" ] ; then
rm -rf $tmpdir
Expand Down

0 comments on commit 735067a

Please sign in to comment.