This tool would remove any extra configuration data from the database. The tool would remove any added columns, config rows, and tables from the database that are not present in the default installation of Discourse. The tool would leave all the content and sitesettings alone. The primary focus would be to remove all plugin and theme components from the database.
The best solution I can think of is set up a new instance from a backup
That’s the cleanest you will get it whilst keeping your forum data without a lot of manual effort.
However, I believe backups will include all the tables that existed in the instance you backed up from and that may include any created by plugins, even if you have not installed the plugin on the new instance.
If you want to get your hands dirty, you can use the rake tasks to drop a database and create a new one and run migrations all over, but that will delete all your data.
This is why “install a new environment and restore a backup” is not the best solution. You still have leftovers from old components and plugins hanging in the database.
There should be a last-effort tool that strips out any component and plugin changes to the database and leaves the data and site settings alone. This tool could be run before going to the new install solution.