How to do website backup using lftp
This article is about using the lftp command line for backup of website data. Of course, if you are backing up data to another VPS or server, rsync backup is recommended, but if you are backing up data to a virtual server that only has an FTP server host, then lftp backup is the best choice.
LFTP is a sophisticated file transfer program supporting a number of network protocols (ftp, http, sftp, fish, torrent). Like BASH, it has job control and uses the readline library for input. It has bookmarks, a built-in mirror command, and can transfer several files in parallel. It was designed with reliability in mind. LFTP is free software, distributed under the GNU GPL license.
lftp ftpsite
lftp -u username,password ftpsite
mirror -R local_directory remote_directory
lftp -u username,password -e “mirror -R –delete –only-newer –verbose local_directory remote_directory” ftpsite
lftp provides some intelligent functions. The at option can easily specify when to run the program. The following command indicates to run every morning:
lftp at 00:00 -u username,password -e “mirror -R –delete –only-newer –verbose local_directory remote_directory” ftpsite &
Now you know how to use lftp to synchronize the local directory and the remote directory, but how to recover when the local server data is lost? Quite simply, you just need to remove the -R option, lftp will download the remote file to the local. Such as:
lftp -u username,password -e “mirror –delete –only-newer –verbose local_directory remote_directory” ftpsite
If you need to know more about lftp commands, you can use the man lftp command to view all the lftp commands.