sync with ftp using lftp

07 Nov 2013 » {[{categoryPostCurrent}]}

Let's say you have a web site hosted on a remote server and you need to keep your local working copy in sync with this remote server. It's a very common use case and under Linux host dedicated server you have a large toolbox to achieve this task; among this tools rsync is the most popular.

But What about this problem on a shared web hosting plateform that have only an ftp server to push your local data? The solution is called lftp. In other words, Lftp is an rsync like program that work over FTP.

Hereunder is the command line that allow you to mirror over FTP your local working copy on a remote server :

lftp ftp://login:password@hostdomain -e "mirror -e --ignore-time -R /my/local/working/copy/ /my/remote/mirror/directory; quit"
  • Here is some explanation:
    • login : the FTP login;
    • password : the FTP password;
    • hostdomain : the IP or the domain of the server;
    • /my/local/working/copy/ is the local working copy as it name suggest;
    • /my/remote/mirror/directory is the remote mirror directory as it name suggest;
    • mirror: make a mirror so it check for local change and according this add new local files and directories; -
    • -e : delete remote files that does not exist anymore locally;
    • -R : transfer is processed from the local to remote direction
    • --ignore-time: compare file without looking for modification on the date/time field;
    • quit: close connection once the job is done;

Voir aussi...

comments powered by Disqus