// you’re reading...

Tips N Tricks

FTP Backups made easy

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!

GD Star Rating
loading...
GD Star Rating
loading...
FTP Backups made easy10.0101
  • Share/Bookmark

Discussion

No comments for “FTP Backups made easy”

Post a comment

Overslept last night to keep my eyes open for a long meeting at UNESCO. But still wish to have a power nap before the meeting ;)
31 minutes ago, comment
Your brain may be overflowing with new ideas today and your se... More for Leo http://twittascope.com/twittascope/?sign=5
31 minutes ago, comment
For the fans RT @wordpress WordPress personas for Firefox: http://short.to/1goju
3 hours ago, comment
Hit by Twitter rate limit in a project. Requested client 2 fill http://tinyurl.com/ye6zwrh Within 24 hrs got mail: 20K requests/hr in 48 hrs
3 hours ago, comment
New blog post: Drupal 6: Different Page Templates for different Content Types http://bit.ly/bfX1yc
3 hours ago, comment