The best way to set up a mirror for Gerrit and all its Git repositories

I have a Gerrit server (named A) and I want to configure the mirror on a new server (named B). I want to pull from B instead of using the computing 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 am using an H2 database, and I want to reflect all Gerrit + all of its Git repositories, and not just Git repositories, because I want to save permissions / history from the Gerrit database.

I managed to narrow down two possible ways to do this:

  • Using 'gerrit replicate' http://gerrit.googlecode.com/svn/documentation/2.1.6/cmd-replicate.html Not sure if this means "[--url <PATTERN>]". Where should I put this command? Is it on server A or B?

  • Use 'rsync', which is fine, but then I cannot sync the review_site / etc / gerrit.config file because it contains the IP address of server A and does not want to have it on server B.

+6
source share
1 answer

A few comments on various issues here:

  • There is no good way to do a hot backup of your database and repositories, especially if you use H2. The only option is to close Gerrit and use a file transfer tool like rsync. If you are using a more reliable database, such as postgres, there is another backup option. However, you still have potential race conditions - if you back up the vaults before the changes are submitted and back up the database after that, you may have problems. This is why we have been working for a long time to get rid of the database and save everything in the repositories.

  • Push vs Pull is not so different from the CPU load on the server (as far as I know). Just use the replication features built into Gerrit, they are designed for this kind of thing.

  • If server B is used only as a backup, if server A is down, I will simply write a script that stops Gerrit on server A in the middle of the night, rsyncs on server B and starts Gerrit. This is the best thing you can do right now, especially with H2.

  • If server B is for your masterโ€™s slave device (so that some users can hit it, and not everyone who hits server A), use Gerrit replication and slave mode - http://gerrit.googlecode.com/svn/documentation/2.1 .6 / config-gerrit.html # container . Please note that this does not back up your database or review changes.

  • Gerrit 2.1.6 is really old. Use at least 2.1.8, 2.2.2 in the near future, and this is your best choice.

  • The gerrit replicate command is intended only to start replication if the server was the last time Gerrit tried to replicate. For instructions on setting up replication using 2.1.6, see http://gerrit.googlecode.com/svn/documentation/2.1.6/config-replication.html

+8
source

Source: https://habr.com/ru/post/905782/


All Articles