I do not recall backing up data over FTP (File Transfer Protocol) in the near past. Thanks to the SSH (Secure SHell) suite of programs like SCP (Secure Copy) and SFTP (Secure FTP), and RSync. But recently I had to setup a scheduled and unattended backup of data lying on a shared hosted server using FTP – the only available option at my disposal.
Wget is a popular and obvious choice to try out for FTP backups. But it didn’t work for me and threw an error saying cannot find .listing file. While I was about to dwell more into wget, I spotted the forgotten hero – lftp. lftp is described as a “Sophisticated file transfer program”. Do not mistake sophistication with complexity. I found it simple to use for my task. I had to backup the data from the hosting server to a Linux based machine (running CentOS). I found lftp preinstalled on the machine. If not found installed, one can install it on a RedHat/Fedora/CentOS based Linux by using the following command:
yum install lftp
To backup using lftp, the syntax is:
lftp -p <FTP-Port> -u ‘<FTP-Username>’,'<FTP-Password>’ -e ‘mirror –verbose <FTP-Directory> <Local-Directory> ;quit’ <FTP-Host>
For example:
lftp -p 21 -u ’shekhar’,’secret’ -e ‘mirror –verbose /public_html /backup/website ;quit’ www.mysite.com
The above command will backup the subdirectories and files in the directory public_html of the website www.mysite.com to a directory named /backup/website on the local machine (on which the lftp command is executed). lftp will automatically create the local directory if it does not exist.
Note that the “mirror” option will backup only the files which have changed. This means for the first time, lftp will download/backup all the files from the site. But subsequently, lftp will backup only the new or edited files and directories. This option saves bandwidth by not re-downloading files, if the backup is up to date.
For scheduled and attended backups you can easily schedule a Cron job with the above command. It’s simple, it works!
Email This Post
⋅
Print This Post
⋅
Post A Comment
@shekharg
Discussion
No comments for “FTP Backups made easy”
Post a comment