How can I mirror/sync a local and remote repository

Asked by Julie Jones

We are trying to setup a Bazaar system for multi-site development. Because we have a low bandwidth internet pipe we intend to have a site repository at each site and a master repository in the cloud. A developer will branch from the site repository to their local machine and then push changes to the site repository. However, we want the cloud master and both site repositories to stay in sync at all times.

Question information

Language:
English Edit question
Status:
Answered
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
John A Meinel (jameinel) said :
#1

I'm not sure what the question is. What you've stated should be fine, you just need to have something keep the repositories in sync.

You're always going to run a little risk of collisions, depending on how you do the synchronization.

It usually helps to have 1 branch be considered the 'trunk' or central-integration branch. Beyond that, you can have groups of branches for each site, in a namespace that makes it so the branches won't conflict.

For example:

 Main site:
  repo/
  repo/trunk
  repo/site-1/
  repo/site-1/branch-1
  repo/site-2/branch-2
...

And then at each site, users could branch from "main/repo/trunk" or from "site/repo/trunk" if they were ok that it could be slightly out of date.

And then an automated job (cron script, etc) could do something like:

 site-1
  cd repo
  bzr pull $main/trunk
  cd site-1/
  for b in *; do bzr push $b $main_site/site-1/$b; done
  cd ../site-2
  for b in `ssh site-2 ls repo/site-2/`; do if [-x $b]; (cd $b; bzr pull); else bzr branch $site-2/$b $b; fi ; done

And the opposite for site-2, etc.

There are ways this could be done more efficiently, sharing ssh connections, etc. You might also look at the "bzr multi-pull" functionality.

It really depends how in-sync you need to be. You could probably run a script like that almost continuously. The main thing to watch out for is that any time you have multiple 'masters' sharing the same namespace, you'll have a chance for two people to try to update both tips. (say you allow people to commit to 'trunk' on both sides.)

You could make site-2's 'trunk' branch a "bound branch" of site-1's trunk. That would prevent you from updating site-2's tip without also updating site-1.

However, people can always get out-of-date from trunk, just because as soon as anyone commits, you're out of date. By using feature branches, you can still get your work done, and then integrate from trunk when you are ready.

Can you help with this problem?

Provide an answer of your own, or ask Julie Jones for more information if necessary.

To post a message you must log in.