Take the 2-minute tour ×

What is a best way to keep in sync two local folders ? I know I can use rsync -Ra but I need to keep in sync all the time. Is it possible to make rsync sit in background and constantly sync local folders.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

If you need to sync directories, and not just have a mirror copy of a directory, I recommend Unison, which we use in our environment. It can keep two local directories synchronized OR a local and a remote directory synchronized.

You can run it as a cron job to check and propagate any changes, or you can fire Unison "on-demand" using incrond which allows you to run Unison only if a file change was detected. I have not used the latter method, so I can't comment on it. We have Unison run every minute via cron to check for changes in the two directories, and it works well for us. It has a built-in lock mechanism so that it won't run another Unison process if one is currently running.

It utilizes rsync behind the scenes, and is very flexible in terms of specifying file exclusions. Priorities are also flexible, for example, if myfile.csv was altered in both directory A and B, so how should Unison handle this? You can use newest, oldest, prefer directory A, prefer directory B, etc...

share|improve this answer

I don't have enough cred to comment so I'll ask this in an answer. What problem are you trying to solve exactly? Is there a reason you can't just use a soft link?

share|improve this answer
I am using vagrant virtual machine and running meteor in it. Vagrant creates shared folder between VM and physical machine, however mongodb don't like that setup and wouldn't start whilst located in shared directory. Unfortunately, I can't make symlinks because os complains it is "read only" although it is not. So as a workaround I am syncing my files from shared directory to /home/vagrant directory and running meteor from /home/vagrant. –  Tom Nov 1 '12 at 17:18
Then check out lsyncd. I've used it to sync directories on remote hosts but no reason it can't be used to sync up 2 local directories –  bluelion Nov 2 '12 at 7:34
lsyncd works fine if I do changes inside VM, however if I do changes on physical machine and changes do appear in VM as well, lsyncd seems to be unable to detect that. –  Tom Nov 2 '12 at 15:17
@Tom did you end up with a good solution to this? I have the same general "slow shared folder in vagrant on windows host" problem –  spike Apr 2 '13 at 22:55

Your Answer


