Detailed steps are outlined in the docs. You should target v9.9.8 as it’s the latest patch version. v9.9.5 will be missing some important updates to security and functionality.
Could you please share the procedure backup the sqlserver before upgrading from 9.9 LTA to v9.9.8 and does it requires Rebuilding indexes for this upgrade ?
You can move your data/es7 folder into your new SonarQube installation directory – but if you notice any discrepancies afterwards, a reindex will be your only option.