Last updated on July 3, 2020 by Dan Nanni
lftp is a command-line FTP client with several advanced file transfer features. For example,
lftp can upload or download a whole directory tree recursively and selectively, or resume interrupted file transfers. A popular use case of
lftp is to mirror local files or folders to a remote FTP server. While
rsync is a popular mirroring software tool, it uses its own file synchronization protocol, and so does not work over FTP.
If you would like to back up local files or directory trees to a remote FTP server, you can proceed as follows.
lftp on Ubuntu, Debian or Linux Mint:
$ sudo apt-get install lftp
lftp on CentOS, Fedora or RHEL:
$ sudo yum install lftp
Now go ahead and run
iftp command as follows. Note that
$ftp_hostname need to be populated according to your FTP server setup.
$ lftp -c "set ftp:list-options -a; open ftp://$username:[email protected]$ftp_hostname; lcd /path/to/local/directory; cd /path/to/remote/directory/in/ftp/server; mirror --reverse --delete --parallel=3 --older-than='now-7days' --exclude-glob .git"
--reverse" option means uploading files to a remote FTP server.
--delete" option means removing files not present in the source directory.
--parallel=3" option means uploading upto 3 files in parallel.
--exclude-glob .git" option means excluding matching folders (e.g.,
--older-than='now-7days'" option means uploading files which were modified more than seven days ago.
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.