Copy the prod db to test db.
That’s what i do with our test instances every now and then.
Afterwards you will have to edit some properties, as sonar.core.serverBaseURL … etc.
I use scripting with Sonarqube web api and Groovy SQL for that.
Note: you must not use multiple Sonarqube instances with one database.
see this post for details