// 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 easy, 10.0 out of 10 based on 1 rating
  • Share/Bookmark

Email This Post Email This Post Print This Post Print This Post Post A Comment Post A Comment Tweet your comments/question to me @shekharg

Discussion

No comments for “FTP Backups made easy”

Post a comment

shekharg: RT @aseemsood: Good news today - Delhi Metro Link between C-Sec and Qutub Minar opens today. http://bit.ly/bCXTbw
17 hours ago, comment
shekharg: I disagree, Twidroyd is the best RT @TweetDeck: New Android TweetDeck Beta is so great that we've skipped v6 & gone straight to 7!
11:05 AM Sep 02, 2010, comment
shekharg: Check out this UI http://nyti.ms/cr0Wcg
10:38 AM Sep 02, 2010, comment
shekharg: Let's declare Gurgaon a part of Pakistan till #CWG2010, to keep away the visitors from seeing the condition of roads here
9:34 AM Sep 02, 2010, comment
shekharg: RT @TechCrunch: Google Making Extraordinary Counteroffers To Stop Flow Of Employees To Facebook - http://tcrn.ch/bpdbYT by @arrington
2:18 PM Sep 01, 2010, comment