With Keycloak 17 running in a docker container, how can we now export/import a realm ?
This was documented for the docker image based on Wildfly but it is no more documented for the docker imaged base on Quarkus.
Previously it was possible to export a realm using this command :
There are import and export commands available for kc.sh.
From the command line:
$ ./kc.sh import --help
Import data from a directory or a file.
Usage:
kc.sh import [OPTIONS]
Import data from a directory or a file.
Options:
--dir <path> Set the path to a directory where files will be created with the exported data.
--file <path> Set the path to a file that will be created with the exported data.
-h, --help This help message.
--override <false> Set if existing data should be skipped or overridden. Default: true.
--realm <realm> Set the name of the realm to export
$ ./kc.sh export --help
Export data from realms to a file or directory.
Usage:
kc.sh export [OPTIONS]
Export data from realms to a file or directory.
Options:
--dir <path> Set the path to a directory where files will be created with the exported data.
--file <path> Set the path to a file that will be created with the exported data.
-h, --help This help message.
--realm <realm> Set the name of the realm to export
--users <strategy> Set how users should be exported. Possible values are: skip, realm_file,
same_file, different_files. Default: different_files.
--users-per-file <number>
Set the number of users per file. It?s used only if --users=different_files.
Default: 50.
I’m also wondering where (or why) the docs are gone and not being updated.
Hello,
thanks for the answer
I understand how it will be possible to do the export once the container is running by calling kc.sh export through docker exec.
But the import of the realm needs to be done automatically when the container is started (which was the case when passing KEYCLOAK_IMPORT environment variable to the docker run command), so calling manually kc.sh import through docker exec is not a solution
Since --import-realm skips import operation if realm already exists, what is the recommended way to do incremental updates to an existing realm (Specially using a container distribution mode)?