Linux – File synchronization between local server and a remote web server

linuxsftpsvnsynchronizationweb-server

I have a local(in office) web server which acts as a testing platform for my website. Also its working as a SVN server to manage my websites code.

Also there's a remote web server where my actual web site is hosted.
I'd need a method, to set a program or mechanism in my local server to sync my remote server with my local server's file system.

This file syncing can be initiated via an automatic method when the local server's file got changed or I'm OK to manually initiate the syncing.

So as an average linux user I'd like to know what kind of mechanism can be followed to achieve this or actually am I doing the correct thing in these kind of requirement?

Best Answer

I'd probably chose a manual method of transferring, but there are plenty of ways to implement it. One of the easiest, and quite secure methods, is to use rsync over ssh. Not only will you be using an encrypted connection, but rsync (after the first synchronization) will then only transfer changes you have made.

The basic syntax is

rsync -<options> -e ssh /local/files user@remote.host.name:/remote/files

There are plenty of additional options you can add, using ssh keys to avoid passwords (and it can then be scripted) for exqample, and there are many interesting options for synchronizing with rsync.