Recursive wget for FTPing a directory structure

I know, I know - you don't use FTP anymore. You've been fully indoctrinated in the Way of Secure Sockets and would never use a protocol that passes your password in plaintext with such a flippant disregard for security. I'm with you.

But sometimes you have to. Someone puts a bunch of files on a server somewhere, emails you an FTP login, and you don't have time to wait on them to upgrade their system for 21st-century standards like FTPS, SFTP, or even SCP. Here's a tip for quickly grabbing a directory structure over FTP to a Linux box.

Using the recursive and FTP switches for wget, we can do this:

wget -r --ftp-username=<username> --ftp-password=<secret> ftp://domain.com/path

That will fetch everything into a new directory structure at ./domain.com/path on your machine. When I used this, I logged into a webserver I control to run the wget FTP datacenter-to-datacenter (bigger pipes) and then tarred and gzipped the result to download it locally.

blog comments powered by Disqus

Posted in Tech Notes
on April 13, 2009