Update SonarQube

Here we explain how to update your SonarQube installation, if you used our documentation for your current installation. Otherwise, following steps can be slightly different. As an example we will show the upgrade procedure to SonarQube 6.7.5.

1. Stop sonar service

$ service sonar stop

2. Backup database

As we are using PostgreSQL as our preferred database, backup command is:

$ pg_dump -U sonar -h localhost sonar > /home/me/sonar.bak

3. Download the new version

3.1 Visit SonarQube download page

3.2 Download the latest SonarQube version

$ wget -P /tmp https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.7.5.zip

4. Extracts to /opt/sonarqube

4.1 Extracts the downloaded file to /opt/sonarqube

$ unzip /tmp/sonarqube-6.7.5.zip -d /opt/sonarqube

$ ls -la /opt/sonarqube
total 20
drwxr-xr-x  5 sonar sonar 4096 Sep 25 09:31 .
drwxr-xr-x  4 root  root  4096 Sep  7  2017 ..
lrwxrwxrwx  1 sonar sonar   30 Aug  6 09:31 sonar -> /opt/sonarqube/sonarqube-5.6.6
drwxr-xr-x 10 sonar sonar 4096 Jun  2  2015 sonarqube-5.1.1
drwxr-xr-x 10 sonar sonar 4096 Feb 16  2017 sonarqube-5.6.6
drwxr-xr-x 11 root  root  4096 Aug  6 10:29 sonarqube-6.7.5

5. Redefine the symbolic link to SonarQube

5.1 Remove current symbolic link

$ rm /opt/sonarqube/sonar

5.2 Create the new symbolic link

$ sudo ln -s /opt/sonarqube/sonarqube-6.7.5 /opt/sonarqube/sonar

5.3 Set the owner of the new files

$ chown sonar:sonar -R /opt/sonarqube

6. Setup properties

6.1 Uncomment the following properties, and set the proper password

# User credentials.

#----- PostgreSQL 8.x/9.x

. . .

6.2 If you want to change the host, port or web context, uncomment and change the proper properties

# Binding IP address

# Web context

# TCP port for incomming connections

. . .
By default, it will use the server IP (if more than one is available, the sonar.web.host property needs to be set) on port 9000 and root context.

7. Setup wrapper

7.1 Change wrapper.java.command to the absolute java path

. . .

8. Start the sonar service

$ service sonar start

9. Update SonarQube

9.1 Open your browser and navigate to https://mydomain/setup

9.2 SonarQube will show a message to upgrade your database, so you must click on Upgrade button

9.3 The databse will be updated and at the end just click on Home link to go back to SonarQube.