This guide covers keeping a CloudSOE SonarQube instance patched on both AWS and Azure: operating-system updates, upgrading SonarQube itself, and moving your analysis history to a fresh CloudSOE image. The image runs on Ubuntu 26.04 LTS and doesn’t include PHP, so PHP2Shell doesn’t apply.

What you can upgrade in place

ComponentIn place?How
Operating system (Ubuntu 26.04 LTS)Yesapt; see Update the operating system
SonarQube Community Build (zip in /opt/sonarqube)Yes, with careSwap in the new release, keep the database; see Upgrade SonarQube
Java (Ubuntu openjdk-21-jre package)YesPatched by apt; restart sonar afterwards
PostgreSQL (Ubuntu postgresql package)Minor updates: yesPatched by apt. Don’t install a different PostgreSQL major version alongside it.
Elasticsearch (bundled with SonarQube)Comes with SonarQubeUpgraded as part of SonarQube; the index rebuilds itself from the database
Kernel and ulimit tuningNothing to dovm.max_map_count and the sonar user limits persist across updates

If your instance is several releases behind, or you’d rather not touch a production server, a fresh image is often the easier route. See Move to a fresh CloudSOE image.

Before you start: back up

Take both a cloud snapshot and a database dump. The snapshot is your one-click rollback. The dump is what you restore onto a new instance, and it’s the only way back once SonarQube has migrated the database to a newer schema.

Cloud disk snapshot

  • AWS: EC2 → Volumes → select the instance’s root volume → Actions → Create snapshot.
  • Azure: your VM → Disks → select the OS disk → Create snapshot.

For a fully consistent snapshot, stop SonarQube first (sudo systemctl stop sonar).

Database dump

Analysis history, issues, quality profiles and gates, users and tokens all live in the PostgreSQL sonarqube database:

sudo -u postgres pg_dump sonarqube | gzip > /home/$(whoami)/sonarqube-db-$(date +%F).sql.gz

Also keep a copy of your configuration and any plugins you installed yourself:

sudo tar czf /home/$(whoami)/sonarqube-conf-$(date +%F).tar.gz \
  /opt/sonarqube/conf/sonar.properties /opt/sonarqube/extensions/plugins
sudo chown $(whoami): /home/$(whoami)/sonarqube-*.gz
chmod 600 /home/$(whoami)/sonarqube-*.gz

sonar.properties contains the database password, so treat the tarball as a secret. The chmod keeps both files readable only by you. Copy both files off the instance before you change anything.

Update the operating system

OS packages, including Java and PostgreSQL, come from Ubuntu’s repositories. Patch on your own schedule:

sudo apt update
apt list --upgradable
sudo apt upgrade

If Java or PostgreSQL was updated, restart SonarQube so it picks up the new versions:

sudo systemctl restart sonar

If an update needs a reboot, Ubuntu creates /var/run/reboot-required:

[ -f /var/run/reboot-required ] && cat /var/run/reboot-required.pkgs
sudo reboot

PostgreSQL and SonarQube are both enabled at boot. SonarQube waits for the database and takes a few minutes to report UP again. Once you’ve rebooted into a new kernel, sudo apt autoremove clears out the old one.

Automatic security updates. Ubuntu normally runs unattended-upgrades for security fixes, and the CloudSOE build doesn’t switch it off. Check what your instance is doing:

systemctl status unattended-upgrades
cat /etc/apt/apt.conf.d/20auto-upgrades

It installs packages but doesn’t reboot or restart SonarQube, so keep an eye on /var/run/reboot-required.

Held packages. apt-mark showhold lists anything pinned at its current version. A held package won’t get security fixes, so release holds you no longer need with sudo apt-mark unhold <package>.

Stay on Ubuntu 26.04. Don’t run do-release-upgrade on this instance. A distro upgrade would also move PostgreSQL to a new major version under SonarQube. When you want a newer Ubuntu release, move to a fresh CloudSOE image instead.

Upgrade SonarQube

The image installs SonarQube Community Build from SonarSource’s official zip into /opt/sonarqube, owned by the sonar user and run by the sonar systemd service. Upgrading means unpacking the new release next to the old one, carrying your configuration across and letting SonarQube migrate the database.

Before you upgrade:

  • Check your current version. It’s in the footer of the web UI, and in VERSION in /etc/cloudsoe-support.txt for the version the image shipped with.
  • Follow SonarSource’s upgrade path. SonarSource publishes which versions you can upgrade from directly. If your instance is older than the documented minimum starting point, you have to step through the intermediate release(s) first. Read the upgrade guide and release notes for your target version in the SonarQube documentation at docs.sonarsource.com before you start.
  • Check the Java requirement in the release notes. The image provides Java 21 (java -version).
  • Check third-party plugins for compatibility with the target version. Incompatible plugins stop SonarQube from starting.
  • You can’t downgrade. Once the new release has migrated the database, going back means restoring your dump.

Upgrade steps. Replace <version> with the full version number of the target release, for example as shown on SonarSource’s download page:

# 1. Download and unpack the new release
cd /var/tmp
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-<version>.zip
unzip -q sonarqube-<version>.zip

# 2. Stop SonarQube and move the old install aside (keep it for rollback)
sudo systemctl stop sonar
sudo mv /opt/sonarqube /opt/sonarqube-old
sudo mv /var/tmp/sonarqube-<version> /opt/sonarqube

# 3. Review what changed in the default config, then carry your config across
sudo diff /opt/sonarqube-old/conf/sonar.properties /opt/sonarqube/conf/sonar.properties
sudo cp /opt/sonarqube-old/conf/sonar.properties /opt/sonarqube/conf/sonar.properties

# 4. Re-install plugins you added yourself (not the bundled ones)
sudo ls /opt/sonarqube-old/extensions/plugins
sudo cp /opt/sonarqube-old/extensions/plugins/<your-plugin>.jar /opt/sonarqube/extensions/plugins/

# 5. Fix ownership and permissions, then start
sudo chown -R sonar:sonar /opt/sonarqube
sudo chmod 640 /opt/sonarqube/conf/sonar.properties
sudo systemctl start sonar

Your copied sonar.properties keeps the database connection, including the per-instance sonar.jdbc.password, and any memory or port settings. Don’t copy the old data/ directory. The new release builds a fresh Elasticsearch index from the database, which is SonarSource’s recommended approach and can take a while on large instances.

Migrate the database. After the new release starts, it reports that the database needs upgrading:

curl -s http://localhost:9000/api/system/status

When the status is DB_MIGRATION_NEEDED, browse to http://<public-ip>:9000/setup and start the upgrade. You can also trigger it from the shell:

curl -s -X POST http://localhost:9000/api/system/migrate_db

Wait until the status reads UP. Large databases can take some time. Follow progress in /opt/sonarqube/logs/web.log.

When everything checks out (see Check everything works), clean up with sudo rm -rf /opt/sonarqube-old /var/tmp/sonarqube-<version>.zip.

Rolling back. Once the database has been migrated, the old release can’t use it. Stop SonarQube, move /opt/sonarqube-old back to /opt/sonarqube, and restore the database from your dump:

sudo systemctl stop sonar
sudo -u postgres dropdb sonarqube
sudo -u postgres createdb -O sonar sonarqube
gunzip -c /home/$(whoami)/sonarqube-db-<date>.sql.gz | sudo -u postgres psql -q -d sonarqube
sudo systemctl start sonar

Or restore the cloud snapshot.

Move to a fresh CloudSOE image

A fresh image gets you the latest Ubuntu patches, the current SonarQube Community Build and a clean install in one step. Everything that matters lives in the database, so the move is mostly a dump and a restore. The old instance keeps running until you switch over.

1. Back up the old instance. Create the database dump and the config/plugins tarball as in Before you start. Stop SonarQube first if you don’t want analyses landing on the old server during the move:

sudo systemctl stop sonar
sudo -u postgres pg_dump sonarqube | gzip > /home/$(whoami)/sonarqube-db-$(date +%F).sql.gz

2. Launch the latest image. Follow the getting-started guide for AWS or Azure. Wait for both first-boot services to finish before you restore anything. They set the new instance’s database password and admin password:

ls /var/lib/sonarqube-firstboot.done /var/lib/sonarqube-admin-password.done
curl -s http://localhost:9000/api/system/status

3. Copy the backups across. Copy them from your workstation (or directly between the instances if they can reach each other):

scp <admin-user>@<old-ip>:'sonarqube-*.gz' .
scp sonarqube-db-<date>.sql.gz sonarqube-conf-<date>.tar.gz <admin-user>@<new-ip>:

4. Restore on the new instance. Replace the new instance’s empty database with your dump:

sudo systemctl stop sonar
sudo -u postgres dropdb sonarqube
sudo -u postgres createdb -O sonar sonarqube
gunzip -c /home/$(whoami)/sonarqube-db-<date>.sql.gz | sudo -u postgres psql -q -d sonarqube

# Remove the Elasticsearch index built for the empty database so it is rebuilt from yours
ls /opt/sonarqube/data
sudo rm -rf /opt/sonarqube/data/es*

Then carry over your customisations, but not the old database password. The new instance’s sonar.properties already holds its own generated sonar.jdbc.password, which matches its PostgreSQL sonar role:

mkdir ~/sonar-restore
sudo tar xzf /home/$(whoami)/sonarqube-conf-<date>.tar.gz -C ~/sonar-restore
sudo diff ~/sonar-restore/opt/sonarqube/conf/sonar.properties /opt/sonarqube/conf/sonar.properties

Re-apply any memory, port or context-path settings you’d changed by editing /opt/sonarqube/conf/sonar.properties. Copy any third-party plugin jars into /opt/sonarqube/extensions/plugins/, if they’re compatible with the new version. Then fix ownership and start:

sudo chown -R sonar:sonar /opt/sonarqube
sudo systemctl start sonar

If the new image runs a newer SonarQube release than the old instance, the status will show DB_MIGRATION_NEEDED. Run the migration as described in Upgrade SonarQube. The same upgrade-path rules apply: a database from a very old release may need an intermediate upgrade first.

Your old logins come with the database. After the restore, users, groups, the admin password and CI tokens are the ones from your old instance. The admin password in the new instance’s /opt/default-sonar-login.txt no longer applies; its DB_PASSWORD still does. Once you’ve checked everything, delete the restore staging copy with rm -rf ~/sonar-restore.

5. Switch clients over. CI pipelines (sonar.host.url), IDE connections, webhooks back from SonarQube, and any reverse proxy or load balancer all point at the old address. Choose one:

  • Move the address. AWS: EC2 → Elastic IPs → re-associate the Elastic IP with the new instance. Azure: dissociate the static public IP from the old VM’s NIC and associate it with the new one.
  • Update DNS. Point your SonarQube hostname at the new instance. Lower the record’s TTL a day in advance.
  • If SonarQube sits behind a load balancer or Application Gateway, swap the target or backend pool member instead.

If you’ve set a Server base URL under Administration → Configuration → General, check it still matches. Update the security group / NSG rules for port 9000 on the new instance to match the old one.

6. Retire the old instance. Keep it stopped, not deleted, for a few days in case something was missed. Then terminate it (AWS) or delete the VM with its disks, NIC and any public IP you didn’t reuse (Azure). Delete old snapshots and dumps once you no longer need them for rollback. The dumps and config tarball contain credentials, so delete them from your workstation too.

Check everything works

Run these after any OS update, SonarQube upgrade or migration:

# Services up
systemctl status postgresql sonar

# Server status: expect "status":"UP" and the version you upgraded to
curl -s http://localhost:9000/api/system/status

# PostgreSQL stays local-only; 9000 is the web port
sudo ss -ltnp | grep -E ':(9000|5432)\b'

# Errors during startup, migration or reindexing
sudo tail -n 50 /opt/sonarqube/logs/sonar.log
sudo grep -iE 'error|exception' /opt/sonarqube/logs/web.log /opt/sonarqube/logs/es.log | tail -n 20

# Runtime versions
java -version
psql --version
sysctl vm.max_map_count

Then, from your own machine:

  • Browse to http://<public-ip>:9000 and sign in with your existing admin account. Administration → System shows the server version and health.
  • Check that your projects, quality gates and issue history are all there. Search results fill in once Elasticsearch has finished reindexing.
  • Run one real analysis from CI with an existing token and confirm the background task completes (Administration → Projects → Background Tasks).

Next steps