Synergy Codeworks

Tips, Tricks, and articles related to open source technology

Jan 07
2010

Using lftp to Recursively Clone Your Website File Tree

Posted by: John Hobart

Tagged in: mirror

The built-in functionality of your plain ol' FTP client doesn't extend to recursively parsing directories and uploading them to a remote machine.   We use lftp to clone our production environment periodically to refresh our development environment.  It's also really useful for migrating your site from host to host.

lftp works similarly to ftp so you shouldn't feel too lost when you fire it up.

$ lftp username@hostname

And here's where lftp really shines - you can use the mirror command to recursively parse a remote site and download it locally, or use mirror -R to reverse the action and upload all your local content to a remote machine.  Just be careful - it doesn't ask for confirmation, so it's really easy to launch it in the wrong direction and blow away all your hard work.

To download a remote file tree just lcd and cd your way to the correct working directories and execute:

> mirror

To do the same thing in reverse, uploading your local content to a remote server:

> mirror -R

As usual there's lots more information in the man pages.  Enjoy!

Also see my blog post on using mysqldump and mysql to replicate your MySQL database from host-to-host.

Comments (1)Add Comment
0
need help
written by Another NooB, February 18, 2010
i want use terminal to upload files one server to second server without any ftp client if that possible plz help me thank x

1832ad@0b6.warzone.lt

u can email me to

Write comment

busy

Client Login