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>
  • email
  • Print
  • Twitter
  • Identi.ca
  • del.icio.us
  • Facebook
This entry was posted in General and tagged download, ftp, lftp, mirror, recursive, sftp, upload. Bookmark the permalink.

14 Responses to Recursive get with lftp

  1. Garrett says:

    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. Andre Pang says:

    lftp: the zsh of ftp clients. Fucken’ A man.

  3. molok says:

    and ‘mirror -R’ to upload a directory… awesome.

  4. Domas says:

    At least in Debian you need to use lftp -e mirror http://ftp.example.com for mirroring remote site.

  5. Jeff Waugh says:

    @Domas: Thanks, I’ve updated the post so it doesn’t suggest direct shell use.

  6. Don says:

    its annoying that you cant do a glob on a directory like:

    > mirror Foobar.*

  7. Dan says:

    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?

  8. herbs says:

    Thanks Jeff – I always wondered how to get the whole bunch with the subdirectories over.

  9. n2j3 says:

    mirror --use-pget-n=5
    to employ lftp’s much vaunted multiple connection mode (and seriously speed up transfer)

  10. Battaglin says:

    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 :-(

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comments will be sent to the moderation queue.