LFTP is a command-line program client for several file transfer protocols. This article discusses LFTP and basic implementation and useful tips.
What is LFTP?
LFTP is a sophisticated ftp/http client, file transfer program supporting a number of network protocols.
Why use FTP?
You have a number of files you need to keep in sync with a remote system that does not support a protocol such as rsync
Installation on CentOS 5
LFTP is included with the stock repo for CentOS 5 this makes installation very easy! All you need to do is install it with yum
yum install lftp
Installation on Ubuntu
Mirroring from CMD
To mirror from a local directory to a remote ftp account you would want to run the following:
lftp -u <username>,<password> -e "mirror --reverse --delete --only-newer <local dir=""> <remote dir="">" <ftp server="">
Where you replace the following variables:
|<local dir>||Directory where your files are Example: /home/user/files|
|<remote dir>||The remote directory to upload to Example: /|
|<ftp server>||The FTP Server you are connecting to Example: ftp.mydomain.com|
You should see a status screen that shows you the uploads. Try running it again, you will see nothing is transferred because they are already there!
Mirroring from script
Great, now everything is working correctly, however, doing it from the command line has a few drawbacks. First, you have to type it in every time, this can be a pain. Second, your username and password would be saved in your history.
- To fix these drawbacks we will want to create a script that has all of the variables in it.
- Edit a file, let's call it lftpcommand.txt (you can call it whatever you want).
- Place the following in the file:
- Now to run the command we will use:
lftp -f lftpcommand.txt
If you have any questions or experience any issues, please reach out to the Support Team, live chat and ticket support are available 24/7.