If it's installed on the server, use rsync
it's build for exactly that job.
To get it bi-directional do this (quote from http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1285799008594+28353475&threadId=1278777) :
To bidirectionally sync a directory /src/foo
on hostA
to /dest/foo
on hostB
, including all the sub-directories, you would run these commands on hostA
:
rsync -auz /src/foo hostB:/dest
rsync -auz hostB:/dest/foo /src
The first command pushes all the files that are newer on hostA
to hostB
.
The second command will pull all the files that are newer on hostB
to hostA
. The
critical options are:
when copying, you must preserve file modification times. -a
does this and
other things;
If you want to preserve just the modification times, use -t
instead.
To skip any files that are newer on the destination: -u
does this.