This is very important that you backup your database (step #7 in the guideline below) in case anything unexpected happens during the migration.
Note that you can upgrade directly from any version to one with a higher version number and all database migrations will be handled automatically during the upgrade process. For example, you can upgrade directly from version 3.1 to version 3.5, without first upgrading to version 3.2, then to version 3.3, and so on.
Stop the SonarQube server
Start the web server
The time to complete an upgrade will vary based on the size of the projects portfolio.
From 5.0 forward, upgrade time can be significantly impacted by the recreation of the Elasticsearch indices, which could take one or more hours, again depending on the size of the projects portfolio.
You can monitor the progress of both the database upgrade and the ES index creation by watching the server log: NEW_SONARQUBE_HOME/logs/sonar.log
An upgrade is complete when an analysis has been run on project. Only then will you see the new functionality.
If, for some reasons, your upgrade failed, you can roll back by:
Restarting the previous version of the web server
Usually the SonarQube releases come with some specific recommendations for upgrading from the previous version. You have to read the upgrade notes for all versions between your current version and the target version.