[keycloak-user] how to clone a realm?

Hongliu Zou hongliu at bondlinc.com
Thu Jul 5 05:37:53 EDT 2018


Hi Madhu

I am facing same issue when try to duplicate realm from file by two simple
steps below
- Export from keyclock A to a file
- Import realm from the file to keycloak B

Error from keyclock log is

org.h2.jdbc.JdbcSQLException: Unique index or primary key violation

After manually change all ids to different value in the file, I can import
now. Maybe write a script to process id to plus 1 for all ids is better. It
looks like export function of keyclock to handle this case is better. Need
input from keycloak experts. :)

Thanks
Hongliu

On Thu, Jul 5, 2018 at 3:31 PM, Sebastian Laskawiec <slaskawi at redhat.com>
wrote:

> Hey Madhu,
>
> How about using import/export functionality [1] (with some manual editing
> or sed/awk magic?
>
> Thanks,
> Sebastian
>
> [1]
> https://www.keycloak.org/docs/latest/server_admin/index.
> html#_export_import
>
> On Thu, Jul 5, 2018 at 9:06 AM Madhu <kkcmadhu at yahoo.com> wrote:
>
> >
> >  Hi,
> > I am using keycloak for a multi tenant/multi realm scenario.
> > In all my realms the clients/roles/password
> > policies/groups/authentication/token settings etc are same.
> > So my idea is to create a template realm and clone it to a new realm
> every
> > time i want to provision a new tenant.
> > I tried using the import/export option, but was not successful. I even
> > tried remvoign all the ids /container id fields from the exported json
> and
> > changed the realm namesand was unsuccessful again.
> > Any idea how to clone a realm?
> > Looks like import/export was built for replicating/duplicating the data
> in
> > another keycloak/database instance, and not suitable for cloning
> /creating
> > a new realm.
> > Any idea how i can create a new realm with defined set of clients, user
> > policies, mappers, authentication settings, flows, token settings and
> roles?
> > Regards,Madhu
> > _______________________________________________
> > keycloak-user mailing list
> > keycloak-user at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/keycloak-user
> >
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>


More information about the keycloak-user mailing list