Linux: Download all file from ftp server recursively
You can use ncftpget command to download entire ftp directory and sub directories from remote ftp server. Let us say you would like to download /www-data directory and all subdirectories inside this one from ftp.nixcraft.net server. You need to use ncftpget command.
Install ncftp client
ncftp client software can be downloaded from http://www.ncftp.com/ncftp/ and works with FreeBSD, Solaris and all most all UNIX variant. You can also run command as follows to install ncftp:
$ sudo apt-get install ncftp
FTP get directory recursively
ncftpget is Internet file transfer program for scripts and advance usage. You need to use command as follows:
$ ncftpget –R –v –u "ftpuser" ftp.nixcraft.net /home/vivek/backup /www-data
Where,
- -R : Copy all subdirectories and files (recursive)
- -v : Verbose i.e. display download activity and progess
- -u "USERNAME" : FTP server username, if skipped ncftpget will try anonymous username
- ftp.nixcraft.net : Ftp server name
- /home/vivek/backup : Download everything to this directory
- /www-data : Remote ftp directory you wish to copy
If you get an error which read as follows:
tar: End of archive volume 1 reached tar: Sorry, unable to determine archive format. Could not read directory listing data: Connection reset by peer
Then add –T option to ncftpget command:
$ ncftpget –T –R –v –u "ftpuser" ftp.nixcraft.net /home/vivek/backup /www-data
Where,
- -T : Do not try to use TAR mode with Recursive mode
E-mail this to a Friend
Printable Version
Is your site working? Monitor Your Web Site 24/7. Get SMS alerts on server downtime. Free 30-day trial including 20 SMS!
You may also be interested in other helpful articles:
- How to recursively go through all local or remote directories
- Ubuntu 6.06 available for download
- Save Disk Space under Apache Web server
- Linux : Upload the files and directory tree to remote ftp server
- nixCraft FAQ roundup - Jan / 7 / 2007
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: apt-get command, ftp directory, FTP Server, get ftp directory recursively, ncftp client, ncftpget command



This is GREAT! I have been struggling with transferring files from multiple partitions on one machine to multiple partitions on another, so NFS doesn’t get it done no matter which isthe server of client. I am now using ProFTPd as a server, and ncftp as a client, and I am watching the partitions fill up as I expected, rather than as NFS and cp -vurf were getting it done.
Thank you for posting this fantastic guide!
Great. I’ve been trying to make a full copy of my ftp site for a backup.