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>
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.
lftp: the zsh of ftp clients. Fucken’ A man.
@Andre Pang: Crazy zsh mans!
and ‘mirror -R’ to upload a directory… awesome.
At least in Debian you need to use lftp -e mirror http://ftp.example.com for mirroring remote site.
@Domas: Thanks, I’ve updated the post so it doesn’t suggest direct shell use.
its annoying that you cant do a glob on a directory like:
> mirror Foobar.*
This should work;
glob -d mirror Foobar.*
Glen, you’re awesome.
And thanks a bunch for this tread guys, really useful.
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?
glob -d -- mirror -c *FoobarThanks Jeff – I always wondered how to get the whole bunch with the subdirectories over.
mirror --use-pget-n=5to employ lftp’s much vaunted multiple connection mode (and seriously speed up transfer)
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
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 ftp://user:pass@ftp-site.gob.ar
> 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 ftp://user:pass@ftp-site.gob.ar
> 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
Looks like
mirror -R
isn’t recursive it’s reverse!!!
Careful!