SonarQube DB Copy Tool
The SonarQube DB Copy Tool is available to customers with Sonar commercial support.
We provide this tool to help you migrate your SonarQube database from one database vendor to another. For example, if you've been using your SonarQube instance with Oracle and want to migrate to PostgreSQL without losing your analysis history, the SonarQube DB Copy Tool can help.
Here's an overview of the general procedure:
- Connect to both the source and target databases.
- Read the data from the source database table by table.
- Save the data into the target database table by table.
- Recreate the sequences, index, and more, on the target database.
The SonarQube DB Copy Tool is provided as a standalone JAR file. You need to make sure you're meeting the following conditions:
- The JAR file must not be installed in your source or target SonarQube instances. You can put the JAR file anywhere on your machine as long as your machine is authorized to access your source and target SonarQube databases.
- You must be using at least version 22.214.171.1247 of the JAR file.
To prepare for the DB Copy Tool, you need to prepare the target instance by setting up a SonarQube schema and populating it with the necessary tables so that your source and target instances have the same database schema.
- Make sure your target database is up and running.
- On your target database, create the
- Download and expand a copy of SonarQube that exactly matches the version you're running.
- Configure your SonarQube copy to connect to the target database. If you've placed your SonarQube copy on the same server that runs your primary SonarQube instance, you'll also need to configure non-default ports for your copy SonarQube instance.
- Start your copy SonarQube instance. It will connect to your empty target and populate the schema.
- Once your copy instance is up and running (indicating that the schema is fully populated), you can stop and delete it.
- Refresh the database statistics on the target database before restarting SonarQube.
At this point, you have the exact same list of tables in your source and target databases.
To run the DB Copy Tool, perform the following steps:
- Stop your primary SonarQube instance.
- Execute the base command jar with the correct parameters.
- Update your primary SonarQube instance's configuration to point to the target DB.
- Restart your primary SonarQube instance.
java -jar sonar-db-copy-126.96.36.1997-jar-with-dependencies.jar
|Print this help information
|JDBC URL of the source database
|Username of the source database
|Password of the source database
|JDBC URL of the target database
|Username of the target database
|Password of the target database
|JDBC Driver of the target database
|JDBC Driver of the source database
|Comma-separated list of tables to migrate
sonar-db-copy verifies if URLs can be reached and the database versions:
When the versions are different, the application stops.
Sometimes when you have restarted the copy, the destination database version is
0. This is not a problem, and the copy will continue.
Then it searches tables in the source and destination databases:
If there are missing tables, you will see this log:
sonar-db-copy truncates tables in the target database and indicates the number of tables purged. Of course, the tables missing can not be purged:
sonar-db-copy reproduces data from source to destination and adjusts the sequence of the destination database after the copy:
If there are some missing tables, you'll see the following warning:
If errors appear during the copy, the process does NOT stop but the errors are displayed:
sonar-db-copy reiterates the difference between the source and destination databases. An error message is displayed if the databases are different.