nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

ftp backup failed with ncftp

This is a discussion on ftp backup failed with ncftp within the Shell scripting forums, part of the Development/Scripting category; hi, i have used the generated backup script from nixCraft. I tried command line to run my scripts, but failed ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 07-08-2008, 01:55 AM
Junior Member
User
 
Join Date: Jul 2008
My distro: centos
Posts: 8
Rep Power: 0
titanium is on a distinguished road
Default ftp backup failed with ncftp

hi, i have used the generated backup script from nixCraft.
I tried command line to run my scripts, but failed at the ncftp area whereby the error is:
=====================
MKD /home/backup/incremental failed; [Create directory operation failed.]
Could not mkdir /home/backup/incremental: server said: Create directory operation failed.
MKD /home/backup/incremental/07-07-2008 failed; [Create directory operation failed.]
Could not mkdir /home/backup/incremental/07-07-2008: server said: Create directory operation failed.
Could not chdir to /home/backup/incremental/07-07-2008: server said: Failed to change directory.
===========================
I am running centos 5 and installed the lastest ncftp-3.2.1-linux-x86-glibc2.3-export.tar.gz file.

i have given permission for the dir to be writable. Any help?
I have searched and found it might be the ncftp config. This is my ncftp config:
### FTP server Setup ###
FTPD="/home/backup/incremental"
FTPU="backup"
FTPP="mypass"
FTPS="my.site.com"
NCFTP=$(which ncftpput)

Thanks if anyone can shed some light.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-08-2008, 02:16 AM
Junior Member
User
 
Join Date: Jul 2008
My distro: centos
Posts: 8
Rep Power: 0
titanium is on a distinguished road
Default

funny thing is that i tried the comman line > ncftp -u backup my.site.com.
login and tried to create dir incremental and change directory it is okay.

but when i invoked my sh script to do the backup, it failed to create the very same directory?

i am using root to run the sh.
Reply With Quote
  #3 (permalink)  
Old 07-09-2008, 08:15 PM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

can you paste your script here? Make sure you use full path name in shell script.
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #4 (permalink)  
Old 07-09-2008, 11:11 PM
Junior Member
User
 
Join Date: Jul 2008
My distro: centos
Posts: 8
Rep Power: 0
titanium is on a distinguished road
Default

Hi my script can be found below. I only changed the server addr and user/pass.

#!/bin/bash
# System + MySQL backup script
# Full backup day - Sun (rest of the day do incremental backup)
# Copyright (c) 2005-2006 nixCraft <Contact / Email us>
# This script is licensed under GNU GPL version 2.0 or above
# Automatically generated by FTP MySQL and Webserver System Backup script
# ---------------------------------------------------------------------
## System Setup ###
DIRS="/var/www/data-backup"
BACKUP=/tmp/backup.$$
NOW=$(date +"%d-%m-%Y")
INCFILE="/root/tar-inc-backup.dat"
DAY=$(date +"%a")
FULLBACKUP="Sun"
### MySQL Setup ###
MUSER="root"
MPASS="mysqlpass"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
### FTP server Setup ###
FTPD="/home/backup/incremental"
FTPU="backup"
FTPP="mypass"
FTPS="my.site.com"
NCFTP=$(which ncftpput)

### Other stuff ###
EMAILID="admin@my.site.com"
### Start Backup for file system ###
[ ! -d $BACKUP ] && mkdir -p $BACKUP || :
### See if we want to make a full backup ###
if [ "$DAY" == "$FULLBACKUP" ]; then
FTPD="/var/www/data-backup/full"
FILE="fs-full-$NOW.tar.gz"
tar -zcvf $BACKUP/$FILE $DIRS
else
i=$(date +"%Hh%Mm%Ss")
FILE="fs-i-$NOW-$i.tar.gz"
tar -g $INCFILE -zcvf $BACKUP/$FILE $DIRS
fi
### Start MySQL Backup ###
# Get all databases name
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").gz
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done
### Dump backup using FTP ###
#Start FTP backup using ncftp
ncftp -u"$FTPU" -p"$FTPP" $FTPS<<EOF
mkdir $FTPD
mkdir $FTPD/$NOW
cd $FTPD/$NOW
lcd $BACKUP
mput *
quit
EOF
### Find out if ftp backup failed or not ###
if [ "$?" == "0" ]; then
rm -f $BACKUP/*
else
T=/tmp/backup.fail
echo "Date: $(date)">$T
echo "Hostname: $(hostname)" >>$T
echo "Backup failed" >>$T
mail -s "BACKUP FAILED" "$EMAILID" <$T
rm -f $T
fi
Reply With Quote
  #5 (permalink)  
Old 07-09-2008, 11:32 PM
Junior Member
User
 
Join Date: Jul 2008
My distro: centos
Posts: 8
Rep Power: 0
titanium is on a distinguished road
Default

if it helps, here is the part where the ncftp failed messages:

NcFTP 3.2.1 (Jul 29, 2007) by Mike Gleason (NcFTP Software: Contacts).
Connecting to 68.178.255.99...
(vsFTPd 2.0.5)
Logging in...
Login successful.
Logged in to my.site.com.
MKD /home/backup/incremental failed; [Create directory operation failed.]
Could not mkdir /home/backup/incremental: server said: Create directory operation failed.
MKD /home/backup/incremental/09-07-2008 failed; [Create directory operation failed.]
Could not mkdir /home/backup/incremental/09-07-2008: server said: Create directory operation failed.
Could not chdir to /home/backup/incremental/09-07-2008: server said: Failed to change directory.
fs-i-09-07-2008-03h22m07s.tar.gz: 1.18 kB 0.98 MB/s
mysql-mytestdata.09-07-2008-03:22:07.gz: 6.97 kB 6.24 MB/s
mysql-information_schema.09-07-2008-03:22:07.gz: 384.00 B 374.25 kB/s
mysql-mysql.09-07-2008-03:22:07.gz: 86.09 kB 34.99 MB/s
mysql-test.09-07-2008-03:22:08.gz: 373.00 B 345.92 kB/s

Thank you for using NcFTP Client.
If you find it useful, please consider making a donation!
NcFTP Client Donations
Reply With Quote
  #6 (permalink)  
Old 07-10-2008, 12:05 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Do you have /home/backup/ directory on FTP server? Are permissions correct on /home/backup/ for ftp user?
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #7 (permalink)  
Old 07-10-2008, 12:10 AM
Junior Member
User
 
Join Date: Jul 2008
My distro: centos
Posts: 8
Rep Power: 0
titanium is on a distinguished road
Default

yes the dir /home/backup does exist and i even chmod 777 to it to test still no luck.

That dir belongs to user "backup".
Is it to do with Vsftpd config? i m guessing cos i googled and some leads to that file.
Reply With Quote
  #8 (permalink)  
Old 07-10-2008, 12:23 AM
Junior Member
User
 
Join Date: Jul 2008
My distro: centos
Posts: 8
Rep Power: 0
titanium is on a distinguished road
Default

guess what, i changed the following:

FTPD="/home/backup/incremental"

to

FTPD="incremental"

and now it works! but not sure if called from cron job will it be oky need to check again.

Based on the above i assume that ncftp logins the user "backup" and using fullpath it failed to create "incremental" dir into its own dir?
or am i doing something wrong with the config?
Reply With Quote
  #9 (permalink)  
Old 07-10-2008, 01:44 AM
Junior Member
User
 
Join Date: Jul 2008
My distro: centos
Posts: 8
Rep Power: 0
titanium is on a distinguished road
Default

look through the ncftp website..found ths line in the manual:

"This version of ncftp no longer does command-line FTP, since the main ncftp program is more of a browser-type program"

Is this the case why fullpath mkdir (i.e. /home/backup/incremental) not working?
Reply With Quote
  #10 (permalink)  
Old 07-10-2008, 01:49 AM
Junior Member
User
 
Join Date: Jul 2008
My distro: centos
Posts: 8
Rep Power: 0
titanium is on a distinguished road
Default

another problem...now i have server A which i want to backup the MySQL data and have this files ftp over to server B.

But server B is having sftp port 22 and ncftp seems not able to connect to sftp. Does this means i need to get another ftp client? any recommendation?

sorry for so many post and questions..need to solve this asap.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Failed to start the X server (your graphical user interface) zillah Linux software 1 12-24-2007 05:57 PM
cdrom: open failed piggy Linux hardware 1 08-02-2007 11:25 PM
mysql connect failed for root raghuram Databases servers 1 02-15-2007 12:06 PM
Re-reading the partition table failed with error 16: Device chiku Linux software 1 12-07-2006 09:45 PM
Failed in mysql_real_connect(): Can't connect to local MySQL Linux software 1 07-17-2006 03:05 AM


All times are GMT +5.5. The time now is 03:43 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36