Skip to content

Commit

Permalink
Move realm export command to script
Browse files Browse the repository at this point in the history
  • Loading branch information
gf-rog committed Mar 20, 2024
1 parent 6f0b693 commit 39a4f57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 0 additions & 5 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,3 @@ services:
- 3000:8080
volumes:
- ./keycloak/realms:/opt/keycloak/data/import

# Export data:
# /opt/keycloak/bin/kc.sh export \
# --dir /opt/keycloak/data/realms \
# --users same_file
17 changes: 17 additions & 0 deletions keycloak/export-realms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
script_path=$(readlink -f "$0")
script_dir=$(dirname "$script_path")

echo "Exporting realms. Please wait a moment..."
docker compose exec keycloak sh -c "
/opt/keycloak/bin/kc.sh export \
--dir /opt/keycloak/data/import \
--users same_file
"

realm_dir="$script_dir/realms"

# Remove ignored master realm files
if ls "$realm_dir" | grep -q master-realm.json; then
rm "$realm_dir/master-realm.json"
rm "$realm_dir/master-users-0.json"
fi

0 comments on commit 39a4f57

Please sign in to comment.