In PHP I would not recommend it for a bunch of reasons.
I have exactly what you need as a python app.
This app is built to run as a service, you simply start it and forget about it :)
App: https://gist.github.com/8f62786582c6933395eb
Shell: https://gist.github.com/e08a99937c6f5deac4ab
Note: the shell file should be called fsyncd not fsyncd.sh :)
The PHP version of the above:
https://gist.github.com/3963cbc58793ff7e9773
Note: You need to get it running on both sites and configure each to connect to the other and set them to be executed by crons. Preferably not by WP crons.
I have the path to the directory that will be synced defined here:
define("PATH_DATA", PATH_ROOT . "data" . DIRECTORY_SEPARATOR);
In my case the data folder is in the script folder. You should just set an absolute path or use the WP core to get the WP uploads dir.
The principal is:
find a way to get the two servers capable of talking to each other.
I used a socket server/client approach.
You could do a HTTP _POST processor (server) and a HTTP _POST maker (client).
Keep a record of last sync time.
At certain intervals read folder for and record any files modified from the last sync time.
Send list of files to be updated with their modified timestamp to the other server.
It should compare your list to his records and tell you which of the files he does not have.
Send those files.
The receiver will write the files and set modified date to the one on the other server. (this is important, to avoid infinite loops)
Good luck.