Below, I describe the complete Sonarqube software upgrade process step by step.

  1. Create a copy of the database of the currently used system version. In my case it was 7.6:
  • Logging in as a sonar user → su - sonar.
  • Backing up the database → pg_dump sonar > sonar_db-$(date +"%Y-%m-%d").sql.
  • Move the copy to your user’s home folder → cp /opt/sonarqube/sonar_db-2021-01-01.sql /home/owned_user/.

2. Download the latest version of the Sonarqube software and upload it to the appropriate directory:

3. Modifying configuration files:

  • Verify that the sonar.properties and wrapper.conf files located in the/opt/sonarqube-7.9.2/conf path have the correct configuration parameters. Compare them with their counterparts located in the same directory of an older version of the system. Do not copy files! Additionally, after installing Java 11, you have to provide the full path to the binary in the wrapper.conf file as a parameter of the wrapper.java.command attribute. In my case the line looks like this → wrapper.java.command=/usr/lib/jvm/java-11-oracle/bin/java.

4. Uploading the necessary plugins:

  • The plugins are located in the directory → /opt/sonarqube-7.9.2/extensions/plugins. Some of them are already installed. Before installing additional ones it is good to verify their compatibility with the site.
  • Plugins can be downloaded directly to the mentioned above directory with the wget command using the links from this page.

5. When the settings in the configuration files are correct and the necessary plugins have been downloaded, stop the current version of the Sonarqube server, start the new one, and then perform the database update:

  • The file that starts the sonarqube service is located in the path → /etc/systemd/system/sonar.service.
  • Stopping the service →service sonar stop.
  • Update service file /etc/systemd/system/sonar.service. Add two lines in the [Service] section. First one LimitNOFILE=65536 is an equivalent of the ulimit -n. Second one LimitNPROC=8192 equivalent of the ulimit -u.
  • Reload the system service manager → systemctl daemon-reload.
  • Enter /opt directory → cd /opt.
  • Delete the symbolic link leading to the existing Sonarqube root directory → rm sonarqube.
  • Create a symbolic link leading to the new system version → ln -s sonarqube-7.9.2 sonarqube.
  • Starting a service (already using the linked new directory) → service sonar start.
  • Go to the page under whose domain Sonarqube is available + add ”/setup”https://sonarqube.example.com/setup. The database update process is started, which in my case took a few seconds. Then the various components of the system are started and the login window is shown.
  • After logging in to your administrator account under the System tab, you can verify that you have the latest (LTS) version.

Optional part: update Java on the server (system requires Java 11 JRE or JDK):

  1. Adding to the system repositories → sudo add-apt-repository ppa:linuxuprising/java.
  2. If it does not exist then create a directory /var/cache/oracle-jdk11-installer-localmkdir -p /var/cache/oracle-jdk11-installer-local.
  3. Download the latest Java 11 from here (account required). It must be the latest, otherwise the installation process will end in an error. This is because the system repository contains information about the latest files that use the latest version of the Java package.
  4. Place the downloaded .tar.gz archive in the directory created above (without this archive, the command in the following section will throw an error).
  5. Run sudo apt update and then sudo apt install oracle-java11-installer-local.
  6. The java executable is located in the path /usr/lib/jvm/java-11-oracle/bin, which must be specified in the wrapper.conf file as I described in the earlier section in step 3.
  7. Optionally, you can perform the installation of the oracle-java11-set-default-local package → sudo apt-get install oracle-java11-set-default-local, to set the installed 11 version of Java as the default.

Disclaimer: This tutorial was done on Ubuntu Server 18.04 LTS with installed 7.6 version of the Sonarqube.