generalsonarqube

Upgrade SonarQube

NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation (Approach B). To identify your Bitnami installation type and what approach to follow, run the command below:

 $ test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

The output of the command indicates which approach (A or B) is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.

It is strongly recommended that you create a backup before starting the update process. If you have important data, it is advisable that you try to create and restore a backup to ensure that everything works properly.

  • Log in to the server console.

  • Create a directory to save all the data you need to backup.

     $ mkdir ~/sonarqube-backup
     $ mkdir ~/sonarqube-backup/httpd
     $ mkdir ~/sonarqube-backup/httpd-ssl
     $ mkdir ~/sonarqube-backup/sonarqube
    
  • Back up the bitnami_sonarqube database as described on the PostgreSQL page.

  • Copy the SonarQube configuration directory to your backup directory. Depending on your installation type, you can use the commands below:

    • Approach A (Bitnami installations using system packages):

       $ sudo cp -rf /opt/bitnami/sonarqube/conf/* ~/sonarqube-backup/sonarqube
      
    • Approach B (Self-contained Bitnami installations):

       $ sudo cp -rf /opt/bitnami/apps/sonarqube/sonarqube/conf/* ~/sonarqube-backup/sonarqube
      
  • Compress the backup directory.

     $ tar cfz sonarqube-backup.tar.gz ~/sonarqube-backup
    
  • Download the backup files sonarqube-backup.tar.gz and backup.sql using SFTP. Refer to the FAQ for more information on this.

  • Launch a new SonarQube server.

  • Upload via SFTP the backups files sonarqube-backup.tar.gz and backup.sql to the new server. Refer to the FAQ for more information on this.

  • Log in to the server console.

  • Restore the database backup as described on the PostgreSQL page.

  • Update the contents of the sonar.properties and wrapper.conf configuration files inside the SonarQube conf directory, with the settings of the related files in the sonarqube-backup/sonarqube backup directory. To do so, use an editor to modify them with the old settings (Web server URL, database, LDAP settings, …).

    NOTE: Depending on your installation type, the SonarQube conf directory can be found in the following locations:

    • Approach A (Bitnami installations using system packages): /opt/bitnami/sonarqube/conf

    • Approach B (Self-contained Bitnami installations): /opt/bitnami/apps/sonarqube/sonarqube/conf


    IMPORTANT: Edit the settings files manually. Do not copy-paste the old files.

  • Check if the plugins installed on the old stack are compatible with the new version of SonarQube by consulting the SonarQube compatibility Matrix. If any of them are incompatible, you will need to install the latest version of these plugins manually as described in the Manual Plugins installation instructions.

  • Restart SonarQube:

     $ sudo /opt/bitnami/ctlscript.sh restart sonarqube
    
  • Browse to http://SERVER-IP/setup and follow the setup instructions (SERVER-IP is a placeholder that you should replace with the actual domain name or IP address of your SonarQube server).

  • Analyze your projects (and compute your Views if you are the owner of the governance product) to get fresh data.

Upgrade only SonarQube in the SonarQube packaged by Bitnami

Download the new version of SonarQube

  • Log in to the server console.

  • Browse to https://www.sonarqube.org/downloads/ and find the link for the latest version of SonarQube.

  • Download the latest version using the link obtained in the previous step. For example (for version 9.0.0), run the commands below:

      $ wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.0.0.45539.zip
      $ unzip sonarqube-9.0.0.45539.zip
    

Backup the current SonarQube installation

Approach A: Bitnami installations using system packages
  • Backup your current SonarQube installation. To do that, use the command:

      $ sudo mv /opt/bitnami/sonarqube /opt/bitnami/sonarqube-backup
    
  • Substitute your old installation with the new version. To do so, execute the following command:

      $ sudo mv ~/sonarqube-9.0.0.45539/ /opt/bitnami/sonarqube
    
  • Update the contents of the /opt/bitnami/sonarqube/conf/sonar.properties and /opt/bitnami/sonarqube/conf/wrapper.conf files with the settings of the related files in the /opt/bitnami/sonarqube-backup/conf backup directory. To do so, use an editor to modify them with the old settings (web server URL, database, LDAP settings, etc.).

    IMPORTANT: Edit the settings files manually. Do not copy-paste the old files.

  • Restore the permissions.

      $ sudo chown -R sonarqube:root /opt/bitnami/sonarqube
    
Approach B: Self-contained Bitnami installations
  • Backup your current SonarQube installation. To do that, use the command:

      $ sudo mv /opt/bitnami/apps/sonarqube/sonarqube /opt/bitnami/apps/sonarqube/sonarqube-backup
    
  • Substitute your old installation with the new version. To do so, use the command below and replace the X.Y.Z placeholder with the version number of the new installation.

      $ sudo mv ~/sonarqube-X.Y.Z/ /opt/bitnami/apps/sonarqube/sonarqube
    
  • Update the contents of the /opt/bitnami/apps/sonarqube/sonarqube/conf/sonar.properties and /opt/bitnami/apps/sonarqube/sonarqube/conf/wrapper.conf files with the settings of the related files in the /opt/bitnami/apps/sonarqube-backup/sonarqube/conf backup directory. To do so, use an editor to modify them with the old settings (web server URL, database, LDAP settings, etc.).

    NOTE: Edit the settings files manually. Do not copy-paste the old files.

  • Restore the permissions.

      $ sudo chown -R root:sonarqube /opt/bitnami/apps/sonarqube/sonarqube
    

Check that the upgrade succeeded

  • Check if the plugins installed on the old stack are compatible with the new version of SonarQube by consulting the SonarQube compatibility Matrix. If any of them are incompatible, you need to install manually the latest version of these plugins as described in the Manual Plugins installation instructions.

  • Restart SonarQube:

     $ sudo /opt/bitnami/ctlscript.sh restart sonarqube
    
  • Browse to http://SERVER-IP/setup and follow the setup instructions (SERVER-IP is a placeholder that you should replace with the actual domain name or IP address of your SonarQube server).

  • Analyze your projects (and compute your Views if you own the Governance product) to get fresh data.

Last modification July 14, 2021