XKeycloak-18 Export Users

Is there another way to export / import users from DB than the CLI? Now from console doesn’t work anymore.

Or a way just to import the users not the whole realm? (like in old KCs)

Thanks

When I try to run the command:

bin/kc.sh export --file /tmp/users.json --users same_file --realm "test"

I get:

2022-07-18 14:47:50,420 INFO  [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000078: Starting JGroups channel `ISPN`
2022-07-18 14:47:50,762 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (import_export) mode
2022-07-18 14:47:50,762 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start caches
2022-07-18 14:47:50,762 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheException: Unable to start JGroups Channel
2022-07-18 14:47:50,762 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: org.infinispan.commons.CacheException: Unable to start JGroups Channel
2022-07-18 14:47:50,763 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Unable to start JGroups Channel
2022-07-18 14:47:50,763 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: no port available in range [7800 .. 7800]

any idea why? thanks!

hello,
were you able to export? How did you figure out the problem?

I had to change the cache mode: bin/kc.sh build --cache=local, do the export and then change back to ispn.

Hello @edwint88
I changed to -cache=local run export. Export ended with following error messages:

2022-12-09 08:03:25,866 DEBUG [org.hibernate.orm.beans] (main) HHH10005004: Stopping BeanContainer : io.quarkus.hibernate.orm.runtime.cdi.QuarkusArcBeanContainer@64641bb2
2022-12-09 08:03:25,869 DEBUG [io.quarkus.arc.impl] (main) ArC DI container shut down
2022-12-09 08:03:25,916 DEBUG [io.quarkus.thread-pool] (main) loop: 1, remaining: 60000000000, intervalRemaining: 5000000000, interruptRemaining: 10000000000
2022-12-09 08:03:25,918 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (import_export) mode
2022-12-09 08:03:25,919 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Unable to start HTTP server
2022-12-09 08:03:25,919 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: io.quarkus.runtime.QuarkusBindException

Files were created but not sure export is successful or not.

Thank & Regards

I guess I had also some errors, but the files were fine. Could you check if you have all your users in files, eventually realm settings?

Hello @edwint88
Thanks for your support.
Export looks like fine if we ignore errors but import doesn’t work properly.
Some workarounds has been mentioned here and here
…but these are new adventures.

I’ll try db migration.

thanks

so if you want just the users to export & import, for me worked without problems. If you want the whole realm then you have different problems.
Either way the best is always to have a db backup.

I need to export-import realm; users are not important in my case. :frowning:

@tirelibirefe the two links u shared, are not relevant to the OP´s Problem. It is that the Cache takes up the port.

The thing that is missing, is that you specific a port for cache, when “starting the export”

@edwint88 your workaround is as of right now the only way. As discussed here for Kubernetes(Bitnami Chart) [keycloak] can not export realm · Issue #13105 · bitnami/charts · GitHub