이 문서는 SonarQube v6.4 기반의 문서로 아카이브 되었습니다.
최신 문서를 참조하십시오.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Next »

Table of Contents

The Sonar DB Copy Tool is provided as part of the Enterprise Edition of SonarQube Supported in Enterprise Edition. 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

Installation

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.

  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/sonar.properties)

  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
  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-1.1-jar-with-dependencies.jar

 

Parameters:

Name

Value

Required ?

Description

-driverDest<jdbc driver>OPTIONALJDBC Driver of the target database
-driverSrc<jdbc driver>OPTIONALJDBC Driver of the source database
-help  Print this parameters help
-urlSrc<jdbc url>REQUIREDJDBC URL of the source database
-userSrc<login>REQUIREDUsername of the source database
-pwdSrc<password>REQUIREDPassword of the source database
-urlDest<jdbc url>REQUIREDJDBC URL of the target database
-userDest<login>REQUIREDUsername of the target database
-pwdDest<password>REQUIREDPassword of the target database
-T OPTIONALComma 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.


  • No labels