LFTP on Windows 10
By Jean-Claude Colette Apr 17, 2019
Here, we explain how to use the Lftp FTP client on Windows 10 through the Windows Subsystem for Linux.
On Windows 10, web site managers typically allow you to automatically update a site by FTP transfer. But If that?s not the case, you must turn to FTP software solutions. A very simple way is to use Unix programs like LFTP. This program can easily update a locally modified website or make a backup of a site.
Installing LFTP on Windows 10
Let's install the Windows subsystem for Linux with a distro like Ubuntu. To do so you can find the procedure in this article. Then open a Bash window to install LFTP:
sudo apt-get install lftp
But this simple installation will not make it possible to use the program successfully because of the Windows firewall.
Let's execute at least once lftp so that the firewall reports an attempt of lftp to connect.
Then allow the LFTP application in the firewall.
To connect to an FTP server (or SFTP server) we need to know the username, the password and possibly the port. Having these required credentials, type the command:
wsl lftp -u username,password host
Connection on another port:
wsl lftp -u username,password -p port host:port
If you have a connection problem, you can add the -d option so that LFTP displays the debug information.
wsl lftp -d -u username,password host
Once logged in, we can use a few commands to display a directory of the remote site etc. Like what:
wsl lftp -d -u username,password ftp.example.com
lftp email@example.com:~> ls
Managing a website with LFTP
We only present here some features of LFTP, used to manage a Web site.
Updating a website
To update its web site on an FTP server:
wsl lftp -u username,password ftp.example.com -d -e "mirror -R /local_site /www; quit"
This command only transfers files modified in the local location and new files to the remote location and deletes files that no longer exist locally in the remote location.
The -e option of LFTP executes the commands in quotation marks.
mirror creates an exact copy.
mirror's -e option erases files that no longer exist.
The -R option specifies that the transfer is from the local location to the remote location.
The -x option indicates the folders that should not be considered in the transfer. We put as many -x "ignored_folder" that there are places to ignore. If there is none, we simply do not put a -x.
The quit command cuts the connection after the transfer.
Downloading a website
To make a backup on your computer of your website, the following command is used:
wsl lftp ftp://username:firstname.lastname@example.org -e "mirror -e -x "ignored_folder" /remote_location /local_location; quit"
This command transfers to the computer only the changed files in the remote location and the new files and deletes the files that no longer exist in the remote location on the computer.
Here is a summary description of the command option:
The -e option executes what is enclosed in quotation marks.
mirror creates an exact copy.
The mirror -e option erases files that no longer exist.
-x refers to folders that should not be considered in the transfer. We put as many -x "ignored_folder" as there are places to ignore. If there is none, we simply do not put a -x.