- 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>
132 lines
3.2 KiB
Markdown
132 lines
3.2 KiB
Markdown
# QuantumRick Backup System
|
|
|
|
Système de sauvegarde automatisé basé sur Restic avec intégration systemd pour services containerisés.
|
|
|
|
## Structure du Projet
|
|
|
|
```
|
|
quantumrick/
|
|
├── backup.env # Configuration centralisée
|
|
├── config/
|
|
│ └── restic.conf # Configuration Restic (générée)
|
|
└── backup/
|
|
├── manage # Interface principale de gestion
|
|
├── gen-conf.sh # Génération de configuration Restic
|
|
├── init-restic.sh # Initialisation repository
|
|
├── install-service # Installation timers systemd
|
|
├── list-snapshots # Liste des snapshots
|
|
├── restore # Restauration
|
|
├── service-backup@.service # Template service systemd
|
|
└── service-backup@.timer # Template timer systemd
|
|
```
|
|
|
|
## Prérequis
|
|
|
|
**IMPORTANT:** Tous les scripts doivent être exécutés dans un environnement ayant sourcé la configuration :
|
|
|
|
```bash
|
|
# Toujours commencer par sourcer la configuration
|
|
source backup.env
|
|
|
|
# Puis exécuter les scripts
|
|
./backup/manage list
|
|
./backup/gen-conf.sh
|
|
./backup/init-restic.sh
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. **Configuration initiale**
|
|
```bash
|
|
# Copier et adapter la configuration
|
|
cp backup.env.sample backup.env
|
|
# Éditer backup.env selon votre environnement
|
|
|
|
# Puis générer la configuration Restic
|
|
source backup.env
|
|
./backup/gen-conf.sh
|
|
```
|
|
|
|
2. **Initialisation du repository**
|
|
```bash
|
|
source backup.env
|
|
./backup/init-restic.sh
|
|
```
|
|
|
|
3. **Installation d'un service**
|
|
```bash
|
|
source backup.env
|
|
sudo ./backup/install-service <nom_service>
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### Variables principales (backup.env)
|
|
|
|
- `BACKUP_USER` : Utilisateur système (défaut: citadel)
|
|
- `PROJECT_ROOT` : Racine du projet
|
|
- `SERVICES_BASE_DIR` : Répertoire des services à sauvegarder
|
|
- `BACKUP_REPOSITORY` : Chemin du repository Restic
|
|
- `DEFAULT_BACKUP_SCHEDULE` : Planning par défaut (défaut: *-*-* 03:00:00)
|
|
|
|
### Personnalisation
|
|
|
|
```bash
|
|
# Exemple pour un autre utilisateur
|
|
export BACKUP_USER="myuser"
|
|
export BACKUP_HOME="/home/myuser"
|
|
source backup.env
|
|
|
|
# Puis utiliser normalement
|
|
./backup/manage list
|
|
```
|
|
|
|
## Utilisation
|
|
|
|
### Gestion des sauvegardes
|
|
```bash
|
|
source backup.env
|
|
|
|
# Lister les timers
|
|
./backup/manage list
|
|
|
|
# Statut d'un service
|
|
./backup/manage status paperless
|
|
|
|
# Lancer une sauvegarde manuelle
|
|
./backup/manage run paperless
|
|
|
|
# Voir les logs
|
|
./backup/manage logs paperless
|
|
```
|
|
|
|
### Restauration
|
|
```bash
|
|
source backup.env
|
|
|
|
# Lister les snapshots
|
|
./backup/list-snapshots paperless
|
|
|
|
# Restaurer en mode test
|
|
./backup/restore paperless --test
|
|
|
|
# Restaurer en production
|
|
./backup/restore paperless --production
|
|
```
|
|
|
|
## Développement
|
|
|
|
Pour contribuer au projet, respectez la convention de sourcer `backup.env` dans tous vos scripts :
|
|
|
|
```bash
|
|
#!/bin/bash
|
|
# Source configuration (scripts doivent être dans backup/)
|
|
source "$(dirname "$(dirname "$0")")/backup.env"
|
|
```
|
|
|
|
## Architecture
|
|
|
|
- **Configuration centralisée** : `backup.env` contient toutes les variables
|
|
- **Scripts modulaires** : Chaque script a une responsabilité spécifique
|
|
- **Templates systemd** : Variables substituées à l'installation
|
|
- **Sécurité** : Mots de passe générés automatiquement |