in General

Recursive get with lftp

If you’re trying to figure out how to recursively download a directory with lftp, the wonderful command-line FTP and SFTP client, this is what you want:

mirror <directory>

… and that’s that. Hopefully this will be more helpful to someone than the current Google documentation results. ;-)

Update: Thanks to molok in the comments, here’s how you upload recursively:

mirror -R <directory>

Write a Comment


Comments will be sent to the moderation queue.


  1. I love lftp. It’s great.

    I use mget all the time, and mirror is really useful as you suggest.

    As a related tip: Did you know you can use lftp on http as well? It understands directory indexing (such as Apache’s) and presents it in the simple lftp interface we all know and love.

  2. Rehi,

    Well lemme take that “Glen, you’re awesome” comment back. Simply because i thoughed “glob -d mirror Foobar.*” would actually work on dirs. Which it does NOT.

    So what i’m really looking for is a way to mirror everydir containing a certain word. “glob -d mirror *Foobar” only mirrored the FIRST dir matching “Foobar”. :(

    Any ideas?

  3. first.. great post
    got this one little problem when using mirror to backup stuff

    lftp -u username,password -e “mirror –delete –only-newer –verbose path/to/source_directory path/to/target_directory” ftpsite

    if I use this in a .sh and want lftp to exit after..what to do? I think I’ve tried almost everything from the lftp man. -f or -c as suggested dont work at all :-(

    • just add the quit to your -e string

      lftp -u username,password -e “mirror –delete –only-newer –verbose path/to/source_directory path/to/target_directory;quit” ftpsite

  4. Thanks for the post and let me know about “mirror”.

    I’m learning to use lftp (It’s great) to synchronize multiple directories (from 2 different computers) throw an ftp server.

    I’m doing something like this to upload:
    > open
    > mirror -R -v –only-newer –delete –verbose /home/source /destination

    and the same, without -R to download my files. It works great, but how can I upload and download multiple directories at once, I mean, instead of:
    > open
    > mirror -R -v –only-newer –delete –verbose /home/source-1 /destination
    > mirror -R -v –only-newer –delete –verbose /home/source-2 /destination
    > mirror -R -v –only-newer –delete –verbose /home/source-3 /destination
    > mirror -R -v –only-newer –delete –verbose /home/source-n /destination