Best way to setup mirror for Gerrit and all of its Git repos

11,581

A few comments on the different issues here:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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

  6. 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

Share:
11,581
samxiao
Author by

samxiao

Working in the Smartphone/Tablets industry as software engineer. Enjoy and interested in all types of new ideas in the technology field. Main focus are on: Java, Ruby, Rspec, Build, SCM, Git, source version control, JUnit, AspectJ, Android, BlackBerry.

Updated on June 08, 2022

Comments

  • samxiao
    samxiao almost 2 years

    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.

    I had managed to narrow down 2 possible ways to do it:

    1. 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?

    2. 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.

  • samxiao
    samxiao over 12 years
    Thanks Brad. Is there a guide for setting up Slave mode? First we do want to have a backup copy of Server A on Server B, but if slave serves the purpose of having a full 2nd copy of Server A on Server B, we will be happy about it. Then we can use it as a mirror and also a backup of the server A content.
  • Brad
    Brad over 12 years
    No, there isn't much documentation on Slave mode that I'm aware of. Like I said above though, Slave mode doesn't back up your database or any changes currently in review, so it isn't a good solution if you are looking for a backup of Server A. Slave mode also won't work with H2. If you are looking for a backup solution, note 3 above is your best bet.
  • samxiao
    samxiao over 12 years
    Hi Brad, I tried Note 3, and rsync seems to be working fine except that I lose all the groups on Server B after restoring. I used "java -jar gerrit.war init -d /srv/server/b/" to re-initialize it. And still won't work the way I wanted. Thanks.
  • wenchiching
    wenchiching over 10 years
    Hi Xbeta, groups info is stored in database(H2 in your case), do you solve this problem?