Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have for example database backups in my linux server and I would like to write a script to upload it to remote FTP. I tried put command, but it can only transfer one file at a time. Then tried mput command, but it just shows me question marks for files I want to transfer (maybe I'm using it wrongly?..)

I tried this:

#!/bin/bash
ftp -n <<EOF
open ftp.server.com
user name password
cd backup
mput /backup/*
EOF

But it won't work. It outputs names of files I want to transfer with question marks at the end of names. Am I missing something or maybe there is better simpler way?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Take a look at ncftp, it comes with an utility (ncftpput) that can be scripted for this purpose:

$ ncftpput -R ftp.server.com /remote/path /backup

The -R flag means recursive mode. You can have your authentication details in a separated file. See the manpage (ncftpput(1)) for details.

share|improve this answer
    
I was about to suggest ncftp too. Use it all the time (and its bookmarks feature is great :)). –  Michael Kjörling Oct 11 '13 at 7:31
    
For some reason it wronlgy installed or didn't install at all. It gives me error -bash: ncftp: command not found. In install log it said it succesffuly installed, but I also saw warnings like these -" insserv: warning: script 'NcFTPd' missing LSB tags and overrides insserv: There is a loop between service redmine and NcFTPd if stopped insserv: loop involving service NcFTPd at depth 2 insserv: loop involving service redmine at depth 1 insserv: Stopping NcFTPd depends on redmine and therefore on system facility `$all' which can not be true!" –  Andrius Oct 11 '13 at 7:38
2  
@Andrius Are you sure that you installed the client and not the server? The error message definitely suggests you installed the server. –  Michael Kjörling Oct 11 '13 at 7:42
    
Right.. How I didn't see that :) –  Andrius Oct 11 '13 at 7:48
    
OK. Thanks, it works now. –  Andrius Oct 11 '13 at 8:00

Another alternative might be to use CurlFtpFS, a FUSE file system driver that exposes a FTP host as a mounted directory (allowing you to access those files with any regular tools, including cp). I don't know how well it works, but from a quick googling around it looks very promising. CurlFtpFS goes back further than does FUSE actually, so should be stable.

To use it, install the appropriate package for your distribution (for example, Arch and Debian use the package name curlftpfs), load the fuse module, and sudo curlftpfs ftp.example.com /mnt/ftp/ -o user=username:password,allow_other, substituting appropriate values for server name, mount point, user name and password.

There are further details at the linked page but that should get you started.

share|improve this answer

You could use lftp

lftp ftp://user:password@domain.ltd -e "mirror -e -R /local/folder /remote/folder ; quit"
share|improve this answer

Your Answer

 
discard

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.