Setting up a development environment is definitely a best practice that helps minimize risks. To do this, first back up your production database and restore it to a new test database. Then install a new SonarQube instance and configure it to use the test database. This creates a completely separate environment for testing.
After the test environment is running, follow the official SonarQube upgrade documentation to perform the upgrade in the test environment first. Once you verify the upgrade is successful and the test environment is functioning correctly, you can apply the same process to production with confidence!