Howto: Use wget Recursively Download All FTP Directories

by on October 26, 2010 · 3 comments· LAST UPDATED October 26, 2010


I would like to copy all of my files and directories from UNIX server to Linux workstation. How do I use wget command to recursively download whole FTP directories stored at /home/tom/ from to local directory called /home/tom/backup?

GNU Wget is a free Linux / UNIX utility for non-interactive download of files from the Web or and FTP servers, as well as retrieval through HTTP proxies. GNU/wget has been designed for robustness over slow dialup internet or unstable network connections. If a download fails due to a network problem, it will keep retrying until the whole file has been retrieved. If the server supports regetting, it will instruct the server to continue the download from where it left off.

wget Recursive Example

You can use the -r ( recursive retrieving ) option as follows. You can also pass your ftp username and password to the wget command. First, make a backup directory in your $HOME directory:

mkdir ~/backup/
cd ~/backup/

Now, use wget command as follows:

wget -r
wget -r
wget -r

wget recursive 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
wget -m
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 3 comments… read them below or add one }

1 Ravi January 25, 2013 at 10:22 pm

the mirroring option is not retaining the time stamp of directories but only of the files in those directories…can you think of a solution where someone would want to retain the directory structure of the same.


2 disney May 22, 2013 at 2:04 am

it assumes the current directory as root so we dont need to specify, but I have a parent directory in parallel to root as var
the below only works and pulls data from root/var/tests and not /var/tests
wget64 -r ftp://root:root@
any suggestions?


3 disney May 22, 2013 at 2:07 am

sorry my pwd is root, so how do I change that for wget64?


Leave a Comment

Tagged as: , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: