Import user assigned roles using pg_restore

Hi, Everybody, I am a French developer and my company has decided to run Keycloak and its Postgresql containerized database on a new host.
We still use jboss/4.8.1.Final but we have replaced the old PostgreSQL 9.4 with PostgreSQL 13.
I used a docker-compose YAML file to run both Postgresql 13 and Keycloak services on the same new host.
I succeded in dumping data from the previous database.
First I imported the clients and realms data with the Keycloak UI, then I used pg_dump and pg_restore (after DROP CASCADE scripts due to constraints) to populate and update the new database because users data cannot be exported with from the application browser UI.
I have to work on live containers and not stop them.
My problem is that after the restore operation all my users are missing assigned values in the tab Role Mapping.
What did I miss? Can you please help me?

Hi,

don’t use the import and export functionality of the UI. Please use the export and import functionality of the command line. See this documentation to export realm with users:
https://www.keycloak.org/docs/latest/server_admin/index.html#_export_import

Best regards
Tobias

1 Like

Thank you Tobias. It works. However I spent a lot of time figuring out where to write the import arguments, how and where to find the dumps and import them.
Regards.

Hi,

I know what you mean. I have done that myself. I’m also a user of keycloak. But that’s for what we developer get paid for.

Best regards
Tobias

1 Like