File Replication

Recently I have been searching around on the internet to find a solution to a recent problem. I need to be able to have two copies of a particular folder (and all the subdirectories and files contained within) on two different servers. The reason being, in the world of web servers and hosting, you need to have redundancy for times of peril. I recently experienced an outage, not on a mission critical server, but on a server nonetheless.

So I did some searching on the internet and kept having the same response, use the Distributed File System built into Win2K3. So I tried that out, and well that didn’t yield any results (I had tried using the DFS before, but to no avail). The problem is that it is simply way too difficult to use. Links, roots, and targets and what they all did were just not worth it. So I decided that maybe I wanted to write my own software to do it, but that rarely works out because I usually get half way through a project and then dump it (or simply not finish it). So it took a Google search, and a hop over to and Sourceforge until I found the perfect fit. At first I didn’t even know that I had found what I needed. The program I found was FreeFileSync. It has an attractive user interface, and is written in C++ (found plenty of programs written in java, but real programs are written in C++). So I installed it tried it out, and it turns out that it has advanced scripting features (aka it can function as a command line tool for sysadmins). The only thing that it lacked was the ability to watch specific folders and propogate changes to mirrored folders. So I decided that I would use C# (I know, Microsoft lacky) to make a little daemon that’ll sit in my system tray and will monitor certain folders and copy them over when needed. I also had to add the program to the Windows startup list (using regedit) so that I don’t need to manually start it every time I shut down a server (which is rare, but happens).

What happened is that I only had to spend an hour fiddling around with some of the most basic code I’ve written in a while and the way that I can watch several folders and then propagate the changes to other folders.

I have included this little project, but I do not warrant that this will work. All you have to do is enter the directory to watch and the script to execute when the directory changes in some way – it looks like this:


sync.cmd being the script generated by FreeFileSync. And that’s it, and its pretty easy. So if you want, download the file here

Please note that you need to download and install FreeFileSync to have everything work.

There are some bugs that I am aware of, but if you have any comments or suggestions please let me know.

Leave a Reply