I tried to upgrade my site from Drupal 8 to Drupal 9. In this process I upgrade the module Permissions by Term to Version 3.0. The upgrade failed due to problems with extension of CiviCRM that were not covered by update report. So I turned back to D8. Afterwards I got the messages that the module Permissions by Term 3.0 was not compatible to D8 and thus disabled. So I downgraded that module by Composer successfully to version 2.31. After trying to reinstall it I got the error message that it couldn't be installed because of existing configuration. In the web I found several ways to delete old configurations, but of course I would like to keep it since I'm afraid I would have to review every page to set permissions again. Thus my questions: Is there any way to reinstall the module without deleting my old configurations (or was my fear wrong)?
Module configuration files are stored in the module's config/install directory. When you enable the module, Drupal tries to install those configurations. If Drupal complains that the configurations already exist, then you can take the following steps:
Identify which configuration files Drupal is complaining about.
Move those configuration files out the module's config/install directory. It doesn't really matter where you move them to, but you're going to want to restore the files after everything is fixed so I suggest just moving them up one level into the config directory.
Try to install the module. Drupal won't find the module's default configuration files that you moved so it shouldn't complain any more.
If Drupal still complains, that means you missed a configuration, so repeat the above steps.
Restore the original configuration files - move them back into config/install.
Note that this is a workaround - not a solution. The module should be examined to ensure it properly removes its own configuration (if appropriate) when uninstalled, and that it declares the proper dependencies in its configuration, and that configurations which are not removed are defined as optional. Please file a bug report in the issue queue for that module so that this can be fixed for other users.
For me I solved the problem by deleting the row permissions_by_term.settings in the table config (after I had realized that there were only a few settings I would be easily able to restore). Afterwards I could install the module. I did get an "unexpected error", but after refreshing the site, the module was marked as installed. But my site still missed the page for the module's settings. This changed after I had deinstalled the module and the reinstalled it again. In this process I lost the settings that had been stored in the tables permissions_by_term_role and permissions_by_term_user (that I could have saved, compare https://www.drupal.org/docs/contributed-modules/permissions-by-term), but since for me they were only few, it didn't matter. Thanks for your help.