Database Migration from Postgres database to sql database

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    We are using SonarQube Version: 9.0.0-enterprise
  • how is SonarQube deployed: zip, Docker, Helm
    We are deploying the Postgres DB, nginx-ingress and SonarQube using helm chart.
  • what are you trying to achieve
    I have an external MS Sql db created in another resource group and I am trying to copy/ migrate the data from Postgres db which is inside the AKS cluster to MS Sql DB which is outside the AKS.

I have installed DB copy tool, I am trying to use below command to migrate data
*java -jar sonar-db-copy-1.6.0.2092-jar-with-dependencies.jar -urlSrc jdbc:postgresql://sonarqubetest.postgres.database.azure.com:5432/sonarDBNew -userSrc sonarUserNew -pwdSrc **** -urlDest 'jdbc:sqlserver://sonarqubenew.database.windows.net:1433;database=sonarnewDB' -userDest sonarUserNew -pwdDest *****

I am getting the below error that cant reach to postgres DB even if I give the correct url,

Exception in thread "main" com.sonar.dbcopy.utils.toolconfig.SqlDbCopyException: Database can not be reached at url jdbc:postgresql://sonarqube-postgresql:5432/sonarDB. Verify url, user name and password.
        at com.sonar.dbcopy.prepare.ConnectionVerifier.databaseIsReached(ConnectionVerifier.java:31)
        at com.sonar.dbcopy.StartApp.main(StartApp.java:71)
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:331)
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:247)
        at org.postgresql.Driver.makeConnection(Driver.java:434)
        at org.postgresql.Driver.connect(Driver.java:291)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
        at com.sonar.dbcopy.prepare.ConnectionVerifier.databaseIsReached(ConnectionVerifier.java:24)
        ... 1 more
Caused by: java.net.UnknownHostException: sonarqube-postgresql
        at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
        at java.base/java.net.Socket.connect(Socket.java:633)
        at org.postgresql.core.PGStream.createSocket(PGStream.java:241)
        at org.postgresql.core.PGStream.<init>(PGStream.java:98)
        at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:109)
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:235)
        ... 8 more
Pods:
NAME                                                  READY   STATUS    RESTARTS         AGE
sonarqube-ingress-nginx-controller-67fb67b5c9-rvdlj   1/1     Running   0                9d
sonarqube-postgresql-0                                1/1     Running   0                26d
sonarqube-sonarqube-0                                 1/1     Running   11 (7d21h ago)   26d

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hi,

Here’s the error

It’s interesting to me that the DB host in the error messages, sonarqube-postgresql doesn’t match what’s in your command, sonarqubetest.postgres.database.azure.com, but I assume that’s about obfuscation/redaction for publication. If it’s not, then I suppose that points to a DNS problem.

 
HTH,
Ann

Hi Ann Cambell

I have tried using sonarqube-postgresql aswell, I was getting the same issue.

Hi,

I don’t know what else to tell you. You need to sort out why your SonarQube instance can’t talk to your DB.

 
Ann

Sorry to confuse you, I am trying to migrate the Database from Postgres Sql to MS Sql Server. In this process I am following a sonarqube documentation to migrate the our Database : SonarQube database copy tool
When I execute the DB copy command, I am getting the above error stating that command could not reach to Postgres Sql DB.

Hi,

Sorry about the confusion. I didn’t read all the way from the top again.

But the answer is still the same: you need to sort out why SonarQube the process can’t connect to your DB.

 
Ann