diff --git a/backup.sh b/backup.sh index 506bb9635b0493dda2efaa9d1aaa12d53e49cf0a..1a061e72e9e52c9d9d22b9ec4c9780f5908930ed 100644 --- a/backup.sh +++ b/backup.sh @@ -1,18 +1,25 @@ #!/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 -if [ ! -d "backups" ]; then - mkdir "backups" -fi +mkdir -p $DIR/backups` -out="backups/keycloak_$(date +%Y%m%d_%H%M).tar.gz" -. .env +out="$DIR/backups/keycloak_$(date +%Y%m%d_%H%M).tar.gz" if command -v docker-compose &> /dev/null; then DOCKER_COMPOSE="docker-compose"