This is an archived version of the documentation for SonarQube-7.2.
See the Latest Documentation for current functionality.

Sonar DB Copy Tool

The Sonar DB Copy Tool is a commercial tool available to Enterprise Editionimages/download/attachments/11639940/onde-sonar-16.png customers. 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.

The version of the JAR to use must be at least

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.

  1. Your source and target database must be up and running

  2. Your SonarQube instance must be temporary stopped during the preparation and the running phase

  3. On your target database, create an empty schema (without the tables)

  4. Configure your SonarQube instance so it connects to the target database. (change properties in your conf/

  5. Start your SonarQube that is going to connect to your empty target database

  6. Once your instance is up and running, you MUST stop it and delete the ElasticSearch index under <sonar_install_dir>/data/es5

  7. At this step, you have on your source and target database the exact same list of tables.

  8. Refresh the Database Statistics on the target database before restarting SonarQube

SonarQube version

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 :

java -jar sonar-db-copy-




Required ?



<jdbc driver>


JDBC Driver of the target database


<jdbc driver>


JDBC Driver of the source database


Print this parameters help


<jdbc url>


JDBC URL of the source database




Username of the source database




Password of the source database


<jdbc url>


JDBC URL of the target database




Username of the target database




Password of the target database



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.