2

I've been using the embedded H2 database with SonarQube 5.1 for a while but am now looking to migrate to a PostgreSQl db, can you advise me on how to do this?

My only worry is that the 'ignore issue' feature will not be ported when moving to the new db, is there any way I can avoid this from happening?

Thanks

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
freedude
  • 73
  • 1
  • 6

2 Answers2

3

As the warning in the footer states quite clearly, you cannot migrate the H2 database. That's why there's a big red warning in the footer when you're using the embedded database. It's for initial evaluation purposes only.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
0

For docker containers and mounting to an external filesystem for sonarqube, there is no sonar.properties except in the docker container. There are environment properties SONARQUBE_JDBC_USERNAME, SONARQUBE_JDBC_PASSWORD, and SONARQUBE_JDBC_URL. However, in the docker compose .yml file, even with those properties, sonarqube new installation (9.9) still defaults only to using h2 internally. I see that sonar has indeed created the sonar user into the postgresql database. But, the view from sonarcube UI in the admin/management section, still says the database in use is h2. I'm missing something but I don't know what, yet. (I attempted migration from sonarqube 6.7.4 to 7.9.2-community but that failed due to a plugin mismatch for which I decided to just take everything to new as the old data/analysis can be disarded. Note that in our configuration for sonarqube 6.7.4 we did not modify the in-container sonar.properties and it talked to the postgresql database fine. Now doing a clean install of v9 and hitting this issue. It's interesting there are no clear docs I've found yet on how to change.)

In version 9x Database H2
Database Version 2.1.214 (2022-06-13)
Username
URL jdbc:h2:tcp://127.0.0.1:9092/sonar
Driver H2 JDBC Driver
Driver Version 2.1.214 (2022-06-13)
Default transaction isolation TRANSACTION_READ_COMMITTED

In version 6.7.4 (which does not have a customized sonar.properties) Database PostgreSQL
Database Version 10.1
Username redacted
URL jdbc:postgresql://sonar_postgresql/sonar
Driver PostgreSQL JDBC Driver
Driver Version 42.2.1

Update: just found this LOL - https://community.sonarsource.com/t/sonarqube-9-8-is-upgraded-to-sonarqube-9-9-and-after-upgrade-there-are-no-projects-visible/86198/7

Sonar decided to change their environment variable names from SONARQUBE_JDBC to SONAR_JDBC. With that update it works to find postgres. However, at a restart of the container, the admin password change is lost, hopefully just as we are now pointing to postgres and no longer h2. https://docs.sonarqube.org/latest/setup-and-upgrade/release-upgrade-notes/#release-9.9-upgrade-notes

BodhiOne
  • 61
  • 1
  • 5