Linux – How to recursively download a folder via FTP on Linux


I'm trying to ftp a folder using the command line ftp client, but so far I've only been able to use 'get' to get individual files.

Best Solution

You could rely on wget which usually handles ftp get properly (at least in my own experience). For example:

wget -r

You can also use -m which is suitable for mirroring. It is currently equivalent to -r -N -l inf.

If you've some special characters in the credential details, you can specify the --user and --password arguments to get it to work. Example with custom login with specific characters:

wget -r --user="user@login" --password="Pa$$wo|^D"

As pointed out by @asmaier, watch out that even if -r is for recursion, it has a default max level of 5:

    Turn on recursive retrieving.

-l depth
    Specify recursion maximum depth level depth.  The default maximum depth is 5.

If you don't want to miss out subdirs, better use the mirroring option, -m:

    Turn on options suitable for mirroring.  This option turns on recursion and time-stamping, sets infinite
    recursion depth and keeps FTP directory listings.  It is currently equivalent to -r -N -l inf