fix: add Redis password authentication support in health check

The health check script was not using the REDIS_HOST_PASSWORD environment
variable when checking Redis connectivity, causing failures when Redis is
password-protected. Now properly detects and uses the password from .env
when available.

Also includes minor cleanup in backup.sh (formatting and redundant log removal).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
BeauTroll
2025-12-17 20:10:20 +01:00
parent dd27bdebb5
commit b693ed1364
2 changed files with 14 additions and 7 deletions

View File

@@ -103,14 +103,14 @@ DATA_SIZE=$(docker-compose exec -T nextcloud du -sb \
# Note: On n'inclut pas la DB car mysqldump est beaucoup plus petit que les fichiers MySQL bruts
# Typiquement: fichiers MySQL = 650MB → dump SQL = 500KB (compression ~99%)
# On ajoute juste 10MB fixe pour DB + config + apps (généralement < 1MB au final)
DB_ESTIMATE=10485760 # 10MB
DB_ESTIMATE=10485760 # 10MB
# Additionner avec 20% de marge
REQUIRED_SPACE=$(echo "$DATA_SIZE + $DB_ESTIMATE" | awk '{total=$1+$3; print int(total*1.2)}')
if [ -z "$REQUIRED_SPACE" ] || [ "$REQUIRED_SPACE" = "0" ]; then
log "WARN" "Impossible de calculer l'espace requis, estimation à 500MB"
REQUIRED_SPACE=500000000 # 500MB par défaut (plus réaliste que 2GB)
REQUIRED_SPACE=500000000 # 500MB par défaut (plus réaliste que 2GB)
fi
# Obtenir l'espace disponible (enlever les espaces/newlines)
@@ -124,7 +124,7 @@ fi
# Note: Nextcloud a beaucoup de fichiers déjà compressés (images, PDFs)
# donc la compression gzip est peu efficace (~30% au lieu de 90%)
if [ "$REQUIRED_SPACE" -gt 0 ] 2>/dev/null; then
ESTIMATED_COMPRESSED=$((REQUIRED_SPACE * 7 / 10)) # 70% de la taille (30% de compression)
ESTIMATED_COMPRESSED=$((REQUIRED_SPACE * 7 / 10)) # 70% de la taille (30% de compression)
log "INFO" "Espace requis (non compressé + 20%): $(numfmt --to=iec-i --suffix=B "$REQUIRED_SPACE" 2>/dev/null || echo "$REQUIRED_SPACE bytes")"
log "INFO" "Espace estimé après compression: $(numfmt --to=iec-i --suffix=B "$ESTIMATED_COMPRESSED" 2>/dev/null || echo "$ESTIMATED_COMPRESSED bytes")"
else
@@ -233,7 +233,6 @@ log "INFO" "Génération du checksum SHA256..."
if cd "$BACKUP_DIR" && sha256sum "$BACKUP_NAME.tar.gz" >"$BACKUP_NAME.tar.gz.sha256"; then
cd "$PROJECT_ROOT"
CHECKSUM=$(cut -d' ' -f1 "$BACKUP_DIR/$BACKUP_NAME.tar.gz.sha256")
log "INFO" "Checksum: $CHECKSUM"
else
cd "$PROJECT_ROOT"
log "WARN" "Impossible de générer le checksum"

View File

@@ -152,10 +152,18 @@ echo ""
# 6. Vérifier Redis
echo "▶ Cache Redis:"
if docker-compose exec -T redis redis-cli ping 2>/dev/null | grep -q "PONG"; then
check_ok "Redis répond"
if [ -n "${REDIS_HOST_PASSWORD:-}" ]; then
if docker-compose exec -T redis redis-cli -a "$REDIS_HOST_PASSWORD" ping 2>/dev/null | grep -q "PONG"; then
check_ok "Redis répond (avec authentification)"
else
check_fail "Redis ne répond pas ou mot de passe incorrect"
fi
else
check_fail "Redis ne répond pas"
if docker-compose exec -T redis redis-cli ping 2>/dev/null | grep -q "PONG"; then
check_ok "Redis répond (sans authentification)"
else
check_fail "Redis ne répond pas"
fi
fi
echo ""