views:

88

answers:

1

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.

A: 

After testing, I believe the answer to this is yes.

As for why I didn't just test this in the first place before asking, I'd misunderstood the way rsync worked and thought that you always needed to set up an rsync daemon on the server.

However if you use ssh as the transfer mechanism then there doesn't need to be an rsync daemon running on the server, just an ssh daemon, which is a lot more common.

In my testing, a newer, changed file on my local machine was overwritten by the older file on the server (even though I had used the --update option).

My conclusion is that rsync is better for master-slave copying/updating, rather than true bidirectional, peer-based synchronization.

I will have to look into Mercurial or possibly Microsoft SyncToy (since both machines are running XP); I will probably go with the latter since it's a simple home network.

Chirael