Working with FTP sites

Posted: - Modified: | geek, linux

One of the Drupal sites I’m working on is on a web host that allows only FTP access, not SSH or SCP access. I set up a local development environment so that I can play around without affecting the integration or production site. This also lets me use drush to do a group upgrade of modules without downloading and installing them one by one. But without the convenience of rsync over ssh, how can I easily transfer my updated code to the server?

lftp is a free Linux/UNIX tool for working with files over FTP. Packages are available on major distros, so installing it as easy as apt-get install lftp or working with your distro’s package manager. To start an lftp session, type lftp user@host. It supports the usual FTP commands, but it also has a few nifty additions. For example, here are some commands I use often:

lftp mirror somedirectory :: Recursively copy somedirectory from the remote computer to the local computer lftp mirror -R somedirectory :: Recursively copy somedirectory from your local computer to the remote computer lftp mirror -R somedirectory destination :: Recursively copy somedirectory to destination – saves me a lot of cd and lcd-ing lftp mirror -R --dry-run somedirectory :: Don’t actually copy somedirectory; print out the commands that would have been run

It’s smart enough to transfer only files that have changed, which is much better than having to remember and copy them. It can also use parallel connections for extra speed.

Type help at the lftp command prompt to find out more, or check out the lftp webpage. Hope this saves you time!

You can comment with Disqus or you can e-mail me at sacha@sachachua.com.