- Add centralized configuration system with backup.env - Move configuration files to proper structure (config/ directory) - Remove hardcoded paths and make system portable - Fix security issue: remove password exposure in gen-conf.sh - Add comprehensive documentation (README.md, CLAUDE.md) - Create configuration template (backup.env.sample) - Add .gitignore to protect sensitive files - Update all scripts to use environment variables - Implement systemd template variable substitution 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
78 lines
2.9 KiB
Bash
78 lines
2.9 KiB
Bash
#!/bin/bash
|
|
# Configuration centralisée pour le système de backup quantumrick
|
|
# Copiez ce fichier vers backup.env et adaptez les valeurs selon votre environnement
|
|
|
|
# === Configuration Utilisateur ===
|
|
# Utilisateur système qui exécutera les backups
|
|
BACKUP_USER="${BACKUP_USER:-citadel}"
|
|
BACKUP_HOME="${BACKUP_HOME:-/home/$BACKUP_USER}"
|
|
|
|
# === Répertoires Principaux ===
|
|
# Racine du projet quantumrick
|
|
PROJECT_ROOT="${PROJECT_ROOT:-/home/nicolas/dev/quantumrick}"
|
|
# Répertoire où les scripts de backup sont installés
|
|
BACKUP_BASE_DIR="${BACKUP_BASE_DIR:-$BACKUP_HOME/backup}"
|
|
# Répertoire contenant les services à sauvegarder
|
|
SERVICES_BASE_DIR="${SERVICES_BASE_DIR:-$BACKUP_HOME/services}"
|
|
# Répertoire de configuration du projet
|
|
CONFIG_DIR="${CONFIG_DIR:-$PROJECT_ROOT/config}"
|
|
|
|
# === Stockage des Sauvegardes ===
|
|
# Chemin de base pour le stockage des backups
|
|
BACKUP_STORAGE_PATH="${BACKUP_STORAGE_PATH:-/mnt/data/backup}"
|
|
# Nom du repository Restic
|
|
BACKUP_REPO_NAME="${BACKUP_REPO_NAME:-quantumrick}"
|
|
# Chemin complet du repository Restic
|
|
BACKUP_REPOSITORY="${BACKUP_REPOSITORY:-$BACKUP_STORAGE_PATH/$BACKUP_REPO_NAME}"
|
|
|
|
# === Système ===
|
|
# Répertoire des services systemd
|
|
SYSTEMD_DIR="${SYSTEMD_DIR:-/etc/systemd/system}"
|
|
# Répertoire des logs système
|
|
LOG_DIR="${LOG_DIR:-/var/log}"
|
|
# Répertoire temporaire
|
|
TEMP_DIR="${TEMP_DIR:-/tmp}"
|
|
|
|
# === Restic Configuration ===
|
|
# Cache Restic
|
|
RESTIC_CACHE_DIR="${RESTIC_CACHE_DIR:-$TEMP_DIR/restic-cache}"
|
|
# Fichier de configuration Restic (généré automatiquement)
|
|
RESTIC_CONFIG_FILE="${RESTIC_CONFIG_FILE:-$CONFIG_DIR/restic.conf}"
|
|
|
|
# === Templates systemd ===
|
|
# Nom des fichiers templates
|
|
SERVICE_TEMPLATE="${SERVICE_TEMPLATE:-service-backup@.service}"
|
|
TIMER_TEMPLATE="${TIMER_TEMPLATE:-service-backup@.timer}"
|
|
|
|
# === Planning par défaut ===
|
|
# Planning de sauvegarde par défaut (format systemd)
|
|
# Exemples: "*-*-* 03:00:00" (quotidien 3h), "Mon *-*-* 04:00:00" (lundi 4h)
|
|
DEFAULT_BACKUP_SCHEDULE="${DEFAULT_BACKUP_SCHEDULE:-*-*-* 03:00:00}"
|
|
|
|
# === Variables d'export pour Restic ===
|
|
export RESTIC_REPOSITORY="$BACKUP_REPOSITORY"
|
|
export RESTIC_CACHE_DIR
|
|
|
|
# Fonction utilitaire pour valider les chemins
|
|
validate_paths() {
|
|
local paths=("$BACKUP_HOME" "$SERVICES_BASE_DIR" "$(dirname "$BACKUP_STORAGE_PATH")")
|
|
for path in "${paths[@]}"; do
|
|
if [[ ! -d "$path" ]]; then
|
|
echo "WARN: Directory $path does not exist" >&2
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Fonction pour afficher la configuration courante
|
|
show_config() {
|
|
echo "=== Configuration Backup ==="
|
|
echo "BACKUP_USER: $BACKUP_USER"
|
|
echo "BACKUP_HOME: $BACKUP_HOME"
|
|
echo "BACKUP_BASE_DIR: $BACKUP_BASE_DIR"
|
|
echo "SERVICES_BASE_DIR: $SERVICES_BASE_DIR"
|
|
echo "BACKUP_REPOSITORY: $BACKUP_REPOSITORY"
|
|
echo "RESTIC_CONFIG_FILE: $RESTIC_CONFIG_FILE"
|
|
echo "SYSTEMD_DIR: $SYSTEMD_DIR"
|
|
echo "LOG_DIR: $LOG_DIR"
|
|
echo "DEFAULT_BACKUP_SCHEDULE: $DEFAULT_BACKUP_SCHEDULE"
|
|
} |