LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Rsync between multiple machines (http://www.linuxquestions.org/questions/linux-general-1/rsync-between-multiple-machines-469391/)

Maeltor 07-31-2006 10:15 AM

Rsync between multiple machines
 
Hi everyone!

I have a design question related to rsync.
My friends and I each have our own local linux servers at our respective homes, and we'd like to set up a directory in each that rysncs to the other two servers. Is this possible?

Example:
I upload a patch to a game on the directory on my local server. At midnight, I want that file to rsync over to my two friends' servers. I want it to work in reverse too, so if they upload I want it to drop to my server as well.

The only major issue I can see with this is, what happens if I upload something and my friend uploads something on the same day. RSYNC will run at night, but both folders will have differences.
Will one server completely overrite the other, thus causing the changes written by one person to be lost?

Is there a better way to accomplish this?

Thanks!

marozsas 07-31-2006 10:55 AM

Yes it is possible and I use very similar setup here.
Just setup one rsync server and let it to copy to or copy from as needed to keep both dirs in sync.

Use compress (-z) to save bandwidth and make the server accept connections only from the other machine. Do not use the --delete option. It is good only for a one-way setup.

If any connection is assymetric (upload is smaller than download) like in ADSL lines, just remember that. It will take a bit longer to transfer files in that direction.

Leave the ports open in your firewall or router and you be fine.

Maeltor 07-31-2006 11:00 AM

So i'll have RSYNC running on only one machine and it will do the pulling and pushing to keep everything in sync.

Sounds good, that should be a fairly easy setup. Thanks!!

Matir 07-31-2006 11:08 AM

I would strongly encourage the use of CVS or Subversion for something like this. If you're both going to be making changes, this will help keep you from blowing away the others changes and help to maintain a central 'repository' for it.

marozsas 07-31-2006 11:12 AM

rsync will run in both machines. In the server, it will accept connection from the client machine. In the server this is done enabling rsync in xinetd and creating a /etc/rsync.conf which defines your sync. Something like this:
Code:

[test]
    comment = test
    path = /export/test
    read only = false
    list = true
    hosts allow = 192.168.155.202

On the client, is where the connection starts. The cmd line for a client may be something like this: "rsync -azrR source_dir rsync://remoteserver/test"

That name "test" identify on the server the sync dir. You can have several sets of sync dirs and they can be syncronized at different times.

good luck !

marozsas 07-31-2006 11:18 AM

Matir brings up a important think here. If you both make changes in the SAME file, CVS or subversion is more appropriated than rsync. In the other hand, if the changes are not in the same file, and you want just to keep a common repository, than rsync could be used, because it has a simpler setup than cvs or subversion.

Matir 07-31-2006 11:51 AM

Quote:

Originally Posted by marozsas
Matir brings up a important think here. If you both make changes in the SAME file, CVS or subversion is more appropriated than rsync. In the other hand, if the changes are not in the same file, and you want just to keep a common repository, than rsync could be used, because it has a simpler setup than cvs or subversion.

Even so, if both people want the same data, you'd need to rsync twice, so changes from A get propagated to B and from B to A.

Maeltor 07-31-2006 11:22 PM

Thanks for all the replies. For now i'm just going to keep a common repository and sync machines from a master RSYNC server.


IE:
Master gets new file uploaded locally, pushes file to Sync machine A, pulls new files from sync machine A that were uploaded that night as well. On the next night it will do the same to B, then the following night to A again and so on.

Does that seem plausible? I'm looking for something just easy to setup right now, i'll get more complicated when i have more time to play around. This isn't critical financial data or anything, just basic documents, some music files, game files, etc.


All times are GMT -5. The time now is 07:57 PM.