How to quickly download or upload directory tree over FTP

The fastest way to download or upload directory tree over FTP using just plain console is to execute lftp command.

lftp is a sophisticated file transfer program which supports protocols like ftp/s, http/s, hftp, fish, sftp and torrent. It is a good idea to install this tool as it can be very handy at times.

To upload local directory local_dir to remote remote_dir on hostname execute:

$ lftp -u username,password -e "mirror -R local_dir /remote_dir;quit" ftp://hostname
Total: 1 directory, 3 files, 0 symlinks
New: 3 files, 0 symlinks
20071573 bytes transferred in 162 seconds (121.8K/s)

To see contents of remote directory remote_dir on hostname execute:

$ lftp -u username,password -e "ls /remote_dir;quit" ftp://hostname
total 19612
-rw-r--r--  1 nobody  nogroup  15568717 Feb 25 23:29 eGroupware.zip
-rw-r--r--  1 nobody  nogroup    113942 Feb 25 23:29 eGroupware-egw-pear.zip
-rw-r--r--  1 nobody  nogroup   4388914 Feb 25 23:30 wordpress.zip

To download remote directory remote_dir on hostname to local local_dir execute:

$ lftp -u username,password -e "mirror /remote_dir local_dir;quit" ftp://hostname
Total: 1 directory, 3 files, 0 symlinks
New: 3 files, 0 symlinks
20071573 bytes transferred in 20 seconds (981.0K/s)

Don't forget to read manual as there are couple of useful options (like downloading or uploading files in parallel).

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a system administrator working for a successful Polish company and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland https://sleeplessbeastie.eu