How to Recursively Download Files from FTP
There are times, when sharing files using email as attachment is not possible, and then one of the best ways is to put those files in a FTP server. You can download those file using wget command line utility. Wget is a free software package for retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols.
In this tutorial we will learn how to Recursively Download Files from FTP.
The basic syntax for wget recursive as below:
# wget -r ftp://ftpuser:ftppassword@ftp.yoursite.com/yourfile Or # wget -r --user="ftpuser" --password="ftppassword" ftp://ftp.yoursite.com/yourfile
-r : recursive Turn on recursive retrieving.
ftp with Mirroring Option:
The -m option turns on mirroring i.e. it turns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings:
# wget -m --user="ftpuser" --password="ftppassword" ftp://ftp.example.com/www
-m : option turns on mirroring
Recursion Maximum Depth Level
Specify recursion maximum depth level depth. The default maximum depth is 5.
# wget -r --level=99 ftp://ftpuser:ftppassword@ftp.example.com/
Additional Parameters:
There are some additional parameters of wget command.
–reject txt,sql : To exclude txt and sql files from downloading.
-nH : avoids the creation of a directory named after the server name
-nc : avoids creating a new file if it already exists on the destination (it is just skipped)
Enjoy it!