Best way to setup mirror for Gerrit and all of its Git repos
I have a Gerrit server (named A), and I want to setup a mirror to a new server (named B).
I want to pull from B instead of using the processing power from A because A serves as the main Gerrit server and I don’t want to put more workload on it when I can mirror it using SSH from B.
I’m using H2 database and I want to mirror the whole Gerrit + all of its Git repos, not just simply Git repos because I want to keep the permissions/history from the Gerrit database too.
- Git mirror repository using two remotes
- When doing a git clone --mirror where are the actual files?
- Syncing one remote git repo with other
- Git local mirror and repository
- Mirror a git repository by pulling?
- Using git to make daily snapshots of a mirror
I had managed to narrow down 2 possible ways to do it:
Using ‘gerrit replicate’ http://gerrit.googlecode.com/svn/documentation/2.1.6/cmd-replicate.html
Not sure what it meant by “[–url < PATTERN >]”. Where should I put run this command? Is it on server A or B?
Use ‘rsync’ which is OK, but then I cannot sync review_site/etc/gerrit.config because it contains the IP of server A and don’t want to have that on server B.
One Solution collect form web for “Best way to setup mirror for Gerrit and all of its Git repos”
A few comments on the different issues here:
There is no good way to perform a hot backup of the database and the repositories, especially if you are using H2. The only option to shut down Gerrit and use a file transfer tool like rsync. If you use a more robust database, like postgres, there are other backup option. However, you still have potential race conditions – if you back up the repositories before a change gets submitted and back up the database after, you might have problems. This is why long-term we are working to get rid of the database and store everything in the repositories.
Push vs Pull is not much different as far as CPU load on the server (as far as I know). Just use the replication features built in to Gerrit, they are designed for this sort of thing.
If Server B is just meant as a backup in case Server A goes down, I’d just write a script which stops Gerrit on Server A in the middle of the night, rsyncs to Server B, and starts Gerrit back up. That is about the best you can do right now, especially with H2.
If Server B is meant to be a slave of your master (so some users can hit it rather than everybody hitting Server A), use Gerrit replication and slave mode – http://gerrit.googlecode.com/svn/documentation/2.1.6/config-gerrit.html#container. Note that this doesn’t backup your database or changes in review.
Gerrit 2.1.6 is really old. Use at least 2.1.8, 2.2.2 will be released soon and is your best bet
The ‘gerrit replicate’ command is just meant to kick off replication in case the server was down the last time Gerrit tried to replicate. The instructions for setting up replication with 2.1.6 are at http://gerrit.googlecode.com/svn/documentation/2.1.6/config-replication.html