title: Best practices of Export/Import Keycloak data in Kubernetes
body: <p>I'm trying to figure out, what is import/export best practices in K8S keycloak(version 3.3.0.CR1). Here is keycloak official page <a href="http://www.keycloak.org/docs/2.0/server_admin_guide/topics/export-import.html" rel="nofollow noreferrer">import/export</a> explanation, and they example of export to single file json. Going to /keycloak/bin folder and the run this:</p>
  <pre><code>./standalone.sh -Dkeycloak.migration.action=export -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=keycloak-export.json
  </code></pre>
  <p>I logged in to pod, and I get errors after run this command:</p>
  <pre><code>12:23:32,045 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation (&quot;add&quot;) failed - address: ([
      (&quot;core-service&quot; =&gt; &quot;management&quot;),
      (&quot;management-interface&quot; =&gt; &quot;http-interface&quot;)
  ]) - failure description: {
      &quot;WFLYCTL0080: Failed services&quot; =&gt; {&quot;org.wildfly.management.http.extensible&quot; =&gt; &quot;java.net.BindException: Address already in use /127.0.0.1:9990&quot;},
      &quot;WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available.&quot; =&gt; {
          &quot;Services that were unable to start:&quot; =&gt; [&quot;org.wildfly.management.http.extensible.shutdown&quot;],
          &quot;Services that may be the cause:&quot; =&gt; [&quot;jboss.remoting.remotingConnectorInfoService.http-remoting-connector&quot;]
      }
  }
  </code></pre>
  <p>As I see, Keycloak server run on the same port, where I ran backup script. Here helm/keycloak values.yml:</p>
  <pre><code>Service:
    Name: keycloak
    Port: 8080
    Type: ClusterIP
  
  Deployment:
    Image: jboss/keycloak
    ImageTag: 2.5.1.Final
    ImagePullPolicy: IfNotPresent
    ContainerPort: 8080
    KeycloakUser: Admin
    KeycloakPassword: Admin
  </code></pre>
  <p>So, server should be stopped, before we ran this scripts? I can't stop keycloak process inside of pod, because ingress will close pod and will create new one.
  Any suggestions for any other way to export/import(backup/restore) data? Or I missing something?</p>
  <p>P.S.
  I even tried UI import/export. Export work good, and I see all data. But import worked in half way. He Brought me all &quot;Clients&quot;, but not my &quot;Realm&quot; and &quot;User Federation&quot;.</p>