Couldn’t fine any info on this in the docs, I wonder if there are any special steps to take into account other than a normal migration of a DB from mysql to postgresql.
Also would using KC import export achieve the same ? I believe this only works per realm but I assumed both master and other realm can be exported.
I’ve never done full realm export / import but I know in other cases not all things get saved, i.e. for Clients, if it s a service account, the service account roles are not saved, so I’m not sure if for full realm import/export things would be missing and its just best to copy the DB?
The exports are not suitable for data backups.
Just do a regular database migration from db A to db B. AFAIK Keycloak does not have special data columns, so this should be feasible with no hassle.
Make a backup of your production environment and test the migration. If it fails, restore the backup, change something and try again. So long, until you are satisfied and everything works.
Thanks for the reply @dasniko I had to switch focus for a while, but came back to this and used pgloader to migrate the data, which when fine till I noticed pgloader creates a schema with dbname, also all tables had been lowercases 
So I re-did the data copy and ensure public schema is used instead, and case is kept, now the odd part is while using the postgresdb I’m getting the “fresh install” Keycloak screen.
But I cloud totally see the data, this is when I also noticed that I had 184 now, not the original 92 or 93 IIRC.
As it turns on in pgsql kc actually uses lowercase unlike with original in mysql 
So I guess I didn’t need to do the extra step with fixing casing.
I haven’t yet redone the process but just wanted to post my findings so far in case others are going trough the same.
Hi @mike-pt
Did you manage to get this working, as I am struggling, I used pgloader to migrate my data, I then exported the data from the schema and imported it into the public schema. I updated my connection string and when I started up Keycloak I get the following message:
keycloak 2024-11-25 12:30:40,999 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:41,290 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:41,388 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:41,491 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:41,587 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:41,786 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:42,286 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:42,986 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:45,031 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:49,599 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (main) Failed to create lock table. Maybe other transaction created in the meantime. Retrying...
keycloak 2024-11-25 12:30:49,615 INFO [org.infinispan.CLUSTER] (main) ISPN000080: Disconnecting JGroups channel `ISPN`
keycloak 2024-11-25 12:30:49,796 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (production) mode
keycloak 2024-11-25 12:30:49,796 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: liquibase.exception.DatabaseException: ERROR: relation "databasechangeloglock" already exists [F
ailed SQL: (0) CREATE TABLE public.databasechangeloglock (ID INTEGER NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WITHOUT TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT databasechangeloglock_pkey PRIMARY KEY (ID))] keycloak 2024-11-25 12:30:49,796 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: ERROR: relation "databasechangeloglock" already exists [Failed SQL: (0) CREATE TABLE public.data
basechangeloglock (ID INTEGER NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WITHOUT TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT databasechangeloglock_pkey PRIMARY KEY (ID))]
keycloak 2024-11-25 12:30:49,797 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: ERROR: relation "databasechangeloglock" already exists