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 backup local files or directory trees to a remote FTP server, you can proceed as follows.
To install lftp on Debian, Ubuntu or Linux Mint:
To install lftp on CentOS, Fedora or RHEL:
Now go ahead and run iftp command as follows. Note that $username, $password and $ftp_hostname need to be populated according to your FTP server setup.
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., .git).
- "--older-than='now-7days'" option means uploading files which were modified more than seven days ago.
Subscribe to Xmodulo
You can have daily Linux tutorials and FAQs delivered to your email inbox. Simply enter your email address below to subscribe to our mailing list. You will receive hands-on guides and carefully written tutorials related to Linux, everything for free.