Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Greetings, I am using ncftpput to transfer a lot of files from on server to the other

ncftpput -f server.txt -vRdb /public_html /var/www/

What happens is, the connection gets cut after about 100 transfers. There are thousands of files that have to be transferred. Problem is after the connection is cut and I reenter the command, it starts from the beginning. Replacing all existing files, making the previous transfer redundant. Is there a way to skip existing files? It's not in the man page so I'm assuming no. So does anybody suggest an alternative command line solution?

share|improve this question
Are you stuck with FTP? Seems like rsync would be the best tool to use here. – innaM Aug 10 '09 at 9:48
sorry forgot to mention that the second server, the receiving end is just a shared host, I only have FTP access – Moak Aug 10 '09 at 9:51
up vote 3 down vote accepted

lftp is a great tool for this, it's scriptable using the mirror command:

 lftp has builtin mirror which can download or update a whole
 directory  tree.  There  is  also reverse mirror (mirror -R)
 which uploads or updates a directory tree on server.  Mirror
 can also synchronize directories between two remote servers,
 using FXP if available.

$ lftp -f


open ftp://<user>:<pass>
set net:timeout 10
set net:max-retries 2
set net:reconnect-interval-base 5
set net:reconnect-interval-multiplier 1
mirror dir1 dir1
share|improve this answer
trying now, still need to reconnect every now and again. Any idea how to automate this? – Moak Aug 10 '09 at 10:25
I have updated my answer – rkthkr Aug 10 '09 at 10:49

You could try to work with ncftpput's -DD option. This will delete the local file after it was successfully transfered. If you don't want to delete files in your /public_html directory, you could copy them to a temporary directory first.

share|improve this answer

FILES=`cat server.txt`
for FILE in $FILES
  if [ ! -d "$FILE" ]; then
    echo "Uploading $FILE..."
    ncftpput -DD -u $FTPUSER -p $FTPPASS $FTPHOST /destination/ftp/dir/$FILE

Don't forget to set the FTPUSER, $FTPPASS, $FTPHOST The -DD option will delete the file after a successful upload. The "! -d "$FILE"" in line 4 will skip directories within server.txt. Don't forget to make the script executable with "chmod 755 yourscriptfile".

share|improve this answer

Have you tried this option?

-A Append to remote files, instead of overwriting them.

(from ncftp site)

share|improve this answer

Try wput

share|improve this answer

Is there any reason why you can't use rsync rather than ftp?

IMO rsync is the right tool for this job. It will only transfer new and changed files, which means that if the transfer dies and has to be restarted, it will pick up from where it left off rather than start from the beginning again.

share|improve this answer
Yes, I would have liked to use RSYNC, however I only had ftp access to the second server. And I think RSYNC doesn't use ftp... – Moak Aug 11 '09 at 11:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.