# Data missing when importing realm

**URL:** <https://forum.keycloak.org/t/data-missing-when-importing-realm/2276>\
**Category:** Configuring the server\
**Created:** [April 22, 2020, 7:39am UTC](https://forum.keycloak.org/t/data-missing-when-importing-realm/2276 "2020-04-22T07:39:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Robinyo](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@Robinyo](https://forum.keycloak.org/u/Robinyo)\
**Post date:** [April 26, 2020, 8:53pm UTC](https://forum.keycloak.org/t/data-missing-when-importing-realm/2276/6 "2020-04-26T20:53:54Z")

</div>

@lrxw

After some more trial and error the following is working for me:

```auto
docker container run -d --name keycloak \
  -p 10001:8080 \
  -v $(pwd):/tmp \
  -e KEYCLOAK_USER=admin \
  -e KEYCLOAK_PASSWORD=secret \
  jboss/keycloak:9.0.3

```

Export:

```auto
docker exec -it keycloak /opt/jboss/keycloak/bin/standalone.sh \
  -Djboss.socket.binding.port-offset=100 \
  -Dkeycloak.migration.action=export \
  -Dkeycloak.migration.provider=singleFile \
  -Dkeycloak.migration.realmName=development \
  -Dkeycloak.migration.usersExportStrategy=REALM_FILE \
  -Dkeycloak.migration.file=/tmp/development-realm.json

```

When the export is complete use `Ctrl-C` to exit the session.

Import the exported file into my Keycloak container.

[Dockerfile](https://github.com/Robinyo/serendipity-api/blob/master/projects/spring-boot/server/services/keycloak/Dockerfile):

```auto
FROM jboss/keycloak:9.0.3

ENV THEME_VERSION 1.0

USER root

RUN microdnf install -y unzip

COPY json /tmp

COPY ./serendipity-keycloak-theme-$THEME_VERSION.zip /opt/jboss/keycloak/themes
RUN cd /opt/jboss/keycloak/themes && \
    unzip serendipity-keycloak-theme-$THEME_VERSION.zip && \
    rm serendipity-keycloak-theme-$THEME_VERSION.zip

```

[docker-compose.yml](https://github.com/Robinyo/serendipity-api/blob/master/projects/spring-boot/server/docker-compose.yml):

```auto
version: '3.7'

services:

  openldap:
    container_name: openldap
    build:
      context: ./services/openldap
      dockerfile: Dockerfile
    env_file: ./services/openldap/openldap.env
    ports:
      - "389:389"

  keycloak:
    container_name: keycloak
    build:
      context: ./services/keycloak
      dockerfile: Dockerfile
    ports:
      - "10001:8080"
    volumes:
      - .:/export
    env_file: ./services/keycloak/keycloak.env

  serendipity-api:
    container_name: serendipity-api
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3001:3001"
    volumes:
      - ./h2:/h2
    environment:
      SPRING_DATASOURCE_URL: jdbc:h2:/h2/serendipity
      AUTO_SERVER: 1
      AUTO_SERVER_PORT: 9091
      DB_CLOSE_DELAY: -1

```

[keycloak.env](https://github.com/Robinyo/serendipity-api/blob/master/projects/spring-boot/server/services/keycloak/keycloak.env):

```auto
KEYCLOAK_USER=admin
KEYCLOAK_PASSWORD=secret
KEYCLOAK_DEFAULT_THEME=serendipity
KEYCLOAK_IMPORT=/tmp/development-realm.json
KEYCLOAK_MIGRATION_STRATEGY=OVERWRITE_EXISTING

```

---

_[View the full topic](https://forum.keycloak.org/t/data-missing-when-importing-realm/2276)._
