Does rsync ignore file timestamps and automatically overwrite on client if file is different on server

rsyncsynchronization

I'm trying to set up two PCs to sync a folder tree so that each PC will have a copy of the tree with the most recent updates to each file.

I considered setting up Mercurial but realized I don't really care about versioning (especially since I'm low on disk space), and that rsync sounds like it does more of what I want – just keeping files up to date, no versions.

However, the page at http://www.linuxjournal.com/content/synchronizing-your-life says the following:

With rsync, any files that already
exist at the destination will not be
transferred. This speeds up the
transfer time considerably. However,
there is still the problem of having
modifications made on both sides. By
default, the rsync program only looks
to see if the files are different in
size and timestamp. It doesn't care
which file is newer, if it is
different, it gets overwritten.

You can pass the '–update' flag to rsync
which will cause it to skip files on
the destination if they are newer than
the file on the source, but only so
long as they are the same type of
file. What this means is that if, for
example, the source file is a regular
file and the destination is a symlink,
the destination file will be
overwritten, regardless of timestamp.
Even looking past its quirks, the
–update flag does not solve the problem because all it does is skip
files on the destination if they are
newer, it doesn't pull those changes
down to the source computer.

Is this correct?

If so, I guess it makes rsync really only useful for backing up one master ("source") machine onto one or more slaves that will get the changes from the master regardless of timestamps. Whereas the problem I'm really trying to solve is having two machines be "peers" and equally just get the most recently updated files from the other.

Or do you think I'll just have to bite the bullet and use git or Mercurial despite the extra disk space for tracking versions?

(Yes I know about Dropbox; I'm well above the 2GB free account limit and not really interested in spending $120-$240 a year when I don't need the cloud storage and something this simple has to have been done before with free & open tools.)

The PCs are both running XP but I was going to use Cygwin's rsync and any other Unixy tools necessary to get the job done.

Best Answer

rsync av --update /loc1 /loc2

so only files that are NEWER will be synced from loc1 to loc2. Logic dictates that any files that are NEWER on loc2 will be untouched. Therefore all the outdated files on loc2 will be up-to-date thanks to loc1

rsync av --update /loc2 /loc1

Now we know that all the files that loc1 had that were newer were copied to loc2. Any files that were older on loc1 (that had newer ones on loc2) remained unchanged. The second rsync command now will update loc1 with files newer on loc2

Et Voila! both locations are synchronised in this example.