Permalink
Browse files

Fix for ftp backup on RHEL5 and Ubuntu

  • Loading branch information...
serghey-rodin committed Oct 12, 2013
1 parent b531e9f commit 735067aa1ae4fc6cc87f3c5f1a8ab9d395502a0d
Showing with 11 additions and 8 deletions.
  1. +5 −4 bin/v-add-backup-ftp-host
  2. +6 −4 bin/v-backup-user
@@ -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
@@ -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"
View
@@ -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
@@ -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
@@ -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

0 comments on commit 735067a

Please sign in to comment.