Skip to content
Snippets Groups Projects
Commit e06eb56a authored by David Beniamine's avatar David Beniamine
Browse files

Merge branch 'services-desk-183-backup' into 'main'

Ajout de backup.sh

See merge request !5
parents 36e8aa02 6d8602ad
Branches
No related tags found
1 merge request!5Ajout de backup.sh
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
keycloak_db/ keycloak_db/
themes/* themes/*
!themes/custom-theme-template !themes/custom-theme-template
backups/*
#!/bin/bash
echo "Backing up Keycloak DB and config"
DIR=$(realpath $(dirname $0))
if [ ! -e $DIR/.env ]
then
echo ".env file do not exist"
exit 1
fi
. $DIR/.env
if [ -z "$MARIADB_PASS" ]; then
echo "Error: the MARIADB_PASS variable is not set or is empty."
exit 1
fi
mkdir -p $DIR/backups
out="$DIR/backups/keycloak_$(date +%Y%m%d_%H%M).tar.gz"
if command -v docker-compose &> /dev/null; then
DOCKER_COMPOSE="docker-compose"
elif docker compose version &> /dev/null; then
DOCKER_COMPOSE="docker compose"
else
echo "'docker compose' and 'docker-compose' not found"
exit 1
fi
$DOCKER_COMPOSE exec -T mariadb mysqldump --all-databases -u root -p"$MARIADB_PASS" --default-character-set=utf8 | gzip > "$out"
ls -lh $out
echo "Done"
...@@ -21,7 +21,7 @@ services: ...@@ -21,7 +21,7 @@ services:
mariadb: mariadb:
image: mariadb:latest image: mariadb:latest
container_name: mariadb container_name: keycloak_mariadb
volumes: volumes:
- "./keycloak_db:/var/lib/mysql:rw" - "./keycloak_db:/var/lib/mysql:rw"
environment: environment:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment