Refactor: Simplify configuration and remove redundant variables

- Remove redundant variables: BACKUP_USER, BACKUP_STORAGE_PATH, BACKUP_REPO_NAME
- Add common Docker variables: PUID, PGID, TZ for centralized management
- Fix PROJECT_ROOT and SERVICES_BASE_DIR path calculations
- Reorganize configuration sections for better clarity
- Export common variables for use across services

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Nicolas Duhamel 2025-06-26 17:53:35 +02:00
parent f314fd06d3
commit b0b9712b52

View File

@ -6,9 +6,16 @@
# Utilisateur système qui exécutera les backups
CITADEL_USER="${CITADEL_USER:-citadel}"
# Racine du projet citadel
PROJECT_ROOT="${PROJECT_ROOT:-/home/nicolas/dev/citadel}"
PROJECT_ROOT="${PROJECT_ROOT:-/home/citadel}"
# Répertoire contenant les services à sauvegarder
SERVICES_BASE_DIR="${SERVICES_BASE_DIR:-/home/$CITADEL_USER/services}"
SERVICES_BASE_DIR="${SERVICES_BASE_DIR:-$PROJECT_ROOT/services}"
# === Variables Communes ===
# User/Group IDs pour les containers Docker
PUID="${PUID:-1000}"
PGID="${PGID:-1000}"
# Timezone globale
TZ="${TZ:-Europe/Paris}"
# === Stockage Restic ===
# Chemin de base pour le stockage des backups
@ -25,7 +32,7 @@ LOG_DIR="${LOG_DIR:-/var/log}"
# Répertoire temporaire
TEMP_DIR="${TEMP_DIR:-/tmp}"
# Fichier de configuration Restic (généré automatiquement)
RESTIC_CONFIG_FILE="${RESTIC_CONFIG_FILE:-$PROJECT_ROOT/config/restic.conf}"
RESTIC_CONFIG_FILE="${RESTIC_CONFIG_FILE:-$HOME/.config/citadel/restic.conf}"
# === Politique de Rétention ===
# Nombre de sauvegardes quotidiennes à conserver
@ -38,14 +45,11 @@ RETENTION_MONTHLY="${RETENTION_MONTHLY:-12}"
RETENTION_YEARLY="${RETENTION_YEARLY:-3}"
# === Variables Dérivées (automatiquement calculées) ===
BACKUP_USER="$CITADEL_USER"
BACKUP_HOME="${BACKUP_HOME:-/home/$CITADEL_USER}"
BACKUP_BASE_DIR="${BACKUP_BASE_DIR:-$BACKUP_HOME/backup}"
BACKUP_STORAGE_PATH="$RESTIC_STORAGE"
BACKUP_REPO_NAME="$RESTIC_REPO"
BACKUP_REPOSITORY="${BACKUP_REPOSITORY:-$RESTIC_STORAGE/$RESTIC_REPO}"
RESTIC_CACHE_DIR="${RESTIC_CACHE_DIR:-$TEMP_DIR/restic-cache}"
CONFIG_DIR="${CONFIG_DIR:-$PROJECT_ROOT/config}"
CONFIG_DIR="${CONFIG_DIR:-$HOME/.config/citadel}"
SYSTEMD_DIR="${SYSTEMD_DIR:-/etc/systemd/system}"
SERVICE_TEMPLATE="${SERVICE_TEMPLATE:-service-backup@.service}"
TIMER_TEMPLATE="${TIMER_TEMPLATE:-service-backup@.timer}"
@ -53,3 +57,8 @@ TIMER_TEMPLATE="${TIMER_TEMPLATE:-service-backup@.timer}"
# === Variables d'export pour Restic ===
export RESTIC_REPOSITORY="$BACKUP_REPOSITORY"
export RESTIC_CACHE_DIR
# === Variables d'export communes ===
export PUID
export PGID
export TZ