Start Free
SonarQube Community Build | Server upgrade and maintenance | Upgrade | Pre-upgrade steps

Pre-upgrade steps

On this page

Before you start

Consider the following before starting your upgrade:

  • SonarQube Community Build releases come with specific recommendations for upgrading from the previous versions. You should first read the release upgrade notes for each version between your current version and the target version.
  • Database disk usage recommendations: During your upgrade, tables may be duplicated to speed up the migration process. This could cause your database disk usage to temporarily increase to as much as double the normal usage. Because of this, we recommend that your database disk usage is below 50% before starting a migration.

Backup the database

First, we strongly recommend creating a backup of your database. A backup dump of the database creates a safety net should anything go wrong during the upgrade process. It also allows for testing the upgrade on a testing instance. See Testing the upgrade section below for details.

For large instances, it can be helpful to perform database maintenance tasks like vacuuming, reindexing, and collecting statistics to ensure a smooth and efficient migration. These steps help eliminate table and index bloat, reclaim disk space, and optimize query performance, preventing unnecessary slowdowns during the upgrade process. 

Additionally, gathering fresh statistics ensures that the database query planner can make optimal execution choices. Neglecting these optimizations can lead to longer upgrade times, increased disk usage, and potential indexing issues, affecting responsiveness after the migration.

PostgreSQL

VACUUM FULL
REINDEX DATABASE <db>
ANALYZE

Oracle

SELECT 'ALTER TABLE ' || OBJECT_NAME || ' MOVE';
  FROM DBA_OBJECTS WHERE OBJECT_TYPE = 'TABLE' AND OWNER = 'SONARQUBE';

BEGIN
  FOR i IN (SELECT INDEX_NAME FROM USER_INDEXES WHERE TABLE_OWNER = 'SONARQUBE') LOOP
    EXECUTE IMMEDIATE 'ALTER INDEX ' || i.INDEX_NAME || ' REBUILD';
  END LOOP;
END;

BEGIN
   DBMS_STATS.GATHER_SCHEMA_STATS('SONARQUBE');
END;

Microsoft SQL Server

EXEC sp_MSforeachtable 'ALTER INDEX ALL ON ? REBUILD';
EXEC sp_MSforeachtable 'UPDATE STATISTICS ? WITH FULLSCAN';

Testing the upgrade

We recommend testing your upgrade to:

  • Make sure your infrastructure can run the upgrade and the new version of SonarQube.
  • Get an idea of how long the upgrade will take.
  • Gain a better understanding of the upgrade process and anticipate what you'll need to do when performing the actual upgrade.

To test your upgrade: 

  1. Create a staging environment using a recent backup of your production database.
    Your staging environment should be as similar to your production instance as possible because the resources and time needed to upgrade depend on what's stored in your database. 
  2. Use this staging environment to test the upgrade.
  3. Observe how long it takes to back up and restore systems and complete the process.

Was this page helpful?

© 2008-2025 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License