Tutorial and tool to help those migrating a gerrit instance with an embedded H2 database to one with mysql (mariadb as well)
We use pure java and jdbc to do data transfer, avoid the problem about encoding and parsing.
"ONLY TESTED WITH VERSION 2.9.1 GERRIT"
The following instruction is only guideline.
Inspired by original support I found:
https://github.com/scprek/gerrit-h2-mysql
- This tool assumes you have a current Gerrit instance with H2 running and knowledge of gerrit
- In order to migrate to a mysql based database, some gerrit settings will need to be changed after the migration
- If you would like to go back to the h2 database, you can use your original settings. However be aware you will lose data if you do so after restarting gerrit and data is published to it.
Create reviewdb database
"ONLY TESTED WITH VERSION 2.9.1 GERRIT"
"MAKE SURE YOU USE THE SAME VERSION OF YOUR CURRENT GERRIT INSTANCE
Just run the standard installation procedure to setup a MySQL instance of Gerrit Code Review in a temporary site path.
You'll wind up with a clean database schema in your MySQL server, and this dummy site directory directory you can clean up later." (from google group forum)
Make sure the gerrit server has the following /etc/gerrit.config
*Note type is mysql even for mariadb
[database]
type = mysql
hostname = <hostname>
port = <port>
database = reviewd
username = root
Shutdown your mysql based temporary gerrit server
java -cp "bin:lib/*" com.ucweb.gerrit.tools.converter.H2ToMySQLLauncher [path/to/old/gerrit.config] [path/to/new/gerrit.config]
See step 2 for gerrit.config options, but do for permanent gerrit instance
As for secure.config add the following
[database]
password = <password>
You can remove the temporary gerrit site, it was only used to initialize the mysql database