Hello! My name is Chris (aka KreCi). I am an independent developer making living from web & mobile application development, website flipping, freelancing & stock photography. Believe me it is my best job ever! Read more...
Web & Android Development, Stock Photography & My Income Online
If you are looking for a solution how to make an automatic copy, backup or synchronized mirror of your files or even a complete website, this article is for you. This solution will copy only new or changed files (incremental copy). So full copy is made only at first run. To make it work you will need ftp or sftp access to server where your files are stored and ssh (or telnet) access to account that you want your files to be mirrored to. To make it work follow this steps:
wget http://tactical.wiretapped.net/mirrors/lftp/ tar xzvf lftp-4.0.2.tar.gz cd lftp-4.0.2 ./configure make
And as root of your system:
make install
If you won’t get any errors during this steps you will have LFTP installed.
mkdir sync cd ./sync
open ftp://yourlogin:yourpassword@sorcedomain.com:22 mirror -c /sourcedir/ /local/target/dir exit
Of course you will need to change “yourlogin”, “yourpassword” and “sourcedomain.com” with your ftp login details. Please save this file.
lftp -f /local/target/yoursyncname.lftp
Don’t forget to change the path to “yoursyncname.lftp” file!
chmod 755 yoursyncname.sh
./yoursyncname.shor put it as a cronjob to make regular mirror.
TIP: If you need to exclude any files or subdirectories from being copied from source directory, you may modify “yoursyncname.lftp” to something like this:
open sftp://yourlogin:yourpassword@sorcedomain.com:22 mirror --exclude cgi-bin --exclude stats -c /sourcedir/ /local/target/dir exit
Thanks for this step by step guide.. I’ve been designing sites for about 10 months now and using ftp to synchronize my files has been something I’ve overlooked. This should make life easier for me.