How to take db backup in keycloak docker container How to take db backup in keycloak docker container database database

How to take db backup in keycloak docker container


the default database is located in /opt/jboss/keycloak/standalone/data/ the name is keycloak.mv.db

if you want to back it up, I suggest mapping a volume when running keycloak:

docker run --volume /root/keycloak/data/:/opt/jboss/keycloak/standalone/data/ ...

this way the database will stay on the host and will keep the changes even if you destroy the container and recreate it.


By default, Keycloak is using its embedded H2 database. I suggest that you move to an external DB so that you will be able to managed backup more simply.

see https://www.keycloak.org/docs/latest/server_installation/index.html#_database and https://github.com/keycloak/keycloak-containers/tree/master/server#database regarding the supported DB and how to setup env variables to connect to the DB from the Keycloak container.

Regards,