This is an archived version of the documentation for SonarQube version 6.4.
See Documentation for current functionality
The Sonar DB Copy Tool is provided as part of the Enterprise Edition of SonarQube . The goal of this tool is to help you on the migration process from one DB vendor to another one. Let's imagine you used to have your SonarQube instance running on Oracle and you want to migrate to MySQL without loosing all your historical analysis. In that context the Sonar DB Copy Tool is there for you. In the following lines we will talk about source and target SonarQube database instances. The source instance is the one running the DB vendor you want to discard and the target the one running the new DB.
The Sonar DB Copy Tool will basically run as follows:
- connect to the source and target database
- read the data of the source database table by table
- save the data into the target database table by table
- recreate the sequences, index, ... on the target database
The Sonar DB Copy Tool is provided as a standalone JAR file. It must not be installed on your source or target SonarQube instance. Put the JAR wherever your want in your machine, the only prerequisites is that this machine must be authorized to access your source and target SonarQube database.
DB Copy Preparation Phase
The goal is to ask your SonarQube Server to create for you the tables (without content) and to have at the end a database schema equals on the source and target database.
- Your source and target database must be up and running
- Your SonarQube instance must be temporary stopped during the preparation and the running phase
On your target database, create an empty schema (without the tables)
Configure your SonarQube instance so it connects to the target database. (change properties in your conf/sonar.properties)
- Start your SonarQube that is going to connect to your empty target database
- Once your instance is up and running, you MUST stop it
- At this step, you have on your source and target database the exact same list of tables.
- Refresh the Database Statistics on the target database before restarting SonarQube
If using a separate SonarQube instance for steps #4, #5 and #6, make sure it runs the same SonarQube version as the original one.
DB Copy Running Phase
Execute the Command :
(jar/version to be replaced with actual latest release)
|-driverDest||<jdbc driver>||OPTIONAL||JDBC Driver of the target database|
|-driverSrc||<jdbc driver>||OPTIONAL||JDBC Driver of the source database|
|-help||Print this parameters help|
|-urlSrc||<jdbc url>||REQUIRED||JDBC URL of the source database|
|-userSrc||<login>||REQUIRED||Username of the source database|
|-pwdSrc||<password>||REQUIRED||Password of the source database|
|-urlDest||<jdbc url>||REQUIRED||JDBC URL of the target database|
|-userDest||<login>||REQUIRED||Username of the target database|
|-pwdDest||<password>||REQUIRED||Password of the target database|
|-T||OPTIONAL||Comma separated list of tables to migrate|
Example of Execution
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 some errors appears during the copy it will NOT stop but displays:
At the end sonar-db-copy resume the difference between source and destination database.