2013/12/22

FTP synchronization. How to update your sites via FTP?

Upload your site via FTP. This is usual offer bundled with web hosting solutions. Nowadays it is mostly SFTP, for secure communication.

There are various sophisticated FTP synchronization solutions. But you can also use simple LFTP script to achieve the same. The lftp command is available in most of the Linux distributions.

Here is example script I put in some of the projects which are deployed as pure static HTML/CSS:

lftp -u username -e "set ssl:verify-certificate no; mirror --reverse --delete --only-newer -v site_source_dir /; exit" ftp.somewebhosting.org

It works like a charm thanks to this reverse mirror approach.

But there are better ways of pushing changes to your static sites. If your are interested, watch out the next post which should appear soon.

4 comments:

  1. Are you aware of http://curlftpfs.sourceforge.net/ ? If so, why don't you use it, with rsync probably?

    ReplyDelete
    Replies
    1. Rsync compares file contents of source and destination. In case of updating website it is unnecessary overhead.

      Delete
    2. According to manual:
      -c, --checksum
      This changes the way rsync checks if the files have been changed and are in need of a transfer. Without this option, rsync uses a "quick check" that (by default) checks if each file's size and time of last modification match between the sender and receiver.

      So it looks that by default rsync also compares only modification time and date.

      Delete
    3. This flag changes the way rsync checks which files have been changed, but does not change the way it computes the deltas to transfer in case of discovering changed files. You are suggesting to use 2 more abstraction layers over simple FTP protocol, which has everything in place to do the job. Only better scriptable FTP client is required, and here comes lftp. I don't see much sense in using curlftpfs+rsync here, and people are complaining that this solution is really slow comparing to lftp mirror mode.

      Delete