title: SonarQube DB Copy Tool
The SonarQube DB Copy Tool is available to Enterprise Edition customers and above.
This tool is provided to help you migrate your SonarQube database from one DB vendor to another. If, for instance, you’ve been using your SonarQube instance with Oracle and you want to migrate to PostgreSQL without loosing your analysis history, the SonarQube DB Copy Tool is what you need.
In the following lines we will talk about “source” and “target” SonarQube database instances. The source instance is the database you want to discard and the target is the one you want to move to.
The procedure is basically as follows:
The SonarQube DB Copy Tool is provided as a standalone JAR file. It must not be installed on your source or target SonarQube instances. Put the JAR wherever your want on your machine, the only prerequisite is that this machine must be authorized to access your source and target SonarQube databases.
The version of the JAR to use must be at least 1.3.1.48
In the preparation phase, you ready the target database by setting up SonarQube schema and populating it with the necessary tables so that you end up with the same database schema in the source and the target.
sonar
schema.At this point, you have in your source and target databases the exact same lists of tables.
There are only four steps in this phase:
java -jar sonar-db-copy-1.3.1.480-jar-with-dependencies.jar
Name | Description | Required
---|---|---|---
-help
|Print this parameters help| no
-urlSrc
|JDBC URL of the source database|yes
-userSrc
|Username of the source database|yes
-pwdSrc
|Password of the source database|yes
-urlDest
|JDBC URL of the target database|yes
-userDest
|Username of the target database|yes
-pwdDest
|Password of the target database|yes
-driverDest
|JDBC Driver of the target database|no
-driverSrc
|JDBC Driver of the source database|no
-T
|Comma separated list of tables to migrate|no
First sonar-db-copy verifies if URLs can be reached and the database versions:
When the versions are different, the application stops.
Sometime when you have restarted the copy, the destination database version is 0. This is not a problem, the copy will continue.
Then it searches tables in source and destination database:
If there are missing tables, you will read this log:
Second sonar-db-copy truncates tables in target database and indicates the number of tables purged:
Of course, the tables missing can not be purged:
Third, sonar-db-copy reproduces data from source to destination and adjusts the sequence of destination database after the copy:
If there are some missing tables:
If errors appear during the copy, the process does NOT stop but the errors are displayed:
At the end sonar-db-copy reiterates the difference between source and destination database.