Hello everyone!
I have keycloak (version 16.1.1) in docker. It works with PostgreSQL (version 14.1). In my docker-compose file I use comands below to exported users from my realm (realm name: Api):
- “-Dkeycloak.migration.action=export”
- “-Dkeycloak.migration.provider=dir”
- “-Dkeycloak.migration.dir=/opt/jboss/keycloak/export”
- “-Dkeycloak.migration.usersExportStrategy=DIFFERENT_FILES”
- “-Dkeycloak.migration.usersPerFile=1”
- “-Dkeycloak.migration.realmName=api”
As the result I have five files, each of them contains one user. File names: api-users-0.json, api-users-1.json, api-users-2.json, api-users-3.json, api-users-4.json, api-users-5.json
Exported file example:
{
“realm” : “api”,
“users” : [ {
“id” : “4fdd554a-e0b9-491d-96c0-76bae82f04b2”,
“createdTimestamp” : 1647520540704,
“username” : “user1”,
“enabled” : true,
“totp” : false,
“emailVerified” : false,
“firstName” : “user1”,
“lastName” : “user1”,
“email” : “user1@mail.ru”,
“credentials” : [ {
“id” : “d85ac2da-844a-4fc8-8f97-3fe2757b959c”,
“type” : “password”,
“createdDate” : 1647520548341,
“secretData” : “{“value”:“FjzXBSMpOUZVZxRCoorlnHlyLIUuzGYD/8/vBvr1SiYOhECTxSySveF57pJCyKhZO3lcYhZkvo6cmYfxLhMLew==”,“salt”:“HQY0HhXYL1xOTGDLCdY4Lw==”,“additionalParameters”:{}}”,
“credentialData” : “{“hashIterations”:27500,“algorithm”:“pbkdf2-sha256”,“additionalParameters”:{}}”
} ],
“disableableCredentialTypes” : [ ],
“requiredActions” : [ ],
“realmRoles” : [ “default-roles-api” ],
“notBefore” : 0,
“groups” : [ ]
} ]
}
After export I deleted all users from the Api realm and copy exported files to the folder /imports. And using comands below imported user. But only from one file.
- “-Dkeycloak.migration.action=import”
- “-Dkeycloak.migration.provider=singleFile”
- “-Dkeycloak.migration.file=/opt/jboss/keycloak/imports/api-users-0.json”
I checed keycloak UI, after importing my realm contains users from file /api-users-0.json.
Alsow using comands below I tried to import users from directory.
- “-Dkeycloak.migration.action=import”
- “-Dkeycloak.migration.provider=dir”
- “-Dkeycloak.migration.dir=/opt/jboss/keycloak/imports”
In the folder /imports I put all five files (api-users-0.json, api-users-1.json, api-users-2.json, api-users-3.json, api-users-4.json, api-users-5.json). In the runing application I have no errors, but users weren’t add to the realm.
Can anybody help me to understand my mistake importing users from directory?