- Move backup/manage to root with auto-sourcing configuration - Create consolidated ./install script (replaces gen-conf.sh + init-restic.sh) - Add protection against direct execution of backup/ scripts - Update documentation (README.md, CLAUDE.md) for new architecture - Remove obsolete gen-conf.sh and init-restic.sh 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
118 lines
3.2 KiB
Markdown
118 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
|
|
├── manage # Interface principale de gestion
|
|
├── install # Script d'installation et configuration
|
|
├── config/
|
|
│ └── restic.conf # Configuration Restic (générée)
|
|
└── backup/
|
|
├── install-service # Installation timers systemd
|
|
├── list-snapshots # Liste des snapshots
|
|
├── restore # Restauration
|
|
├── service-backup@.service # Template service systemd
|
|
└── service-backup@.timer # Template timer systemd
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. **Configuration initiale**
|
|
```bash
|
|
# Copier et adapter la configuration
|
|
cp backup.env.sample backup.env
|
|
# Éditer backup.env selon votre environnement
|
|
```
|
|
|
|
2. **Installation complète**
|
|
```bash
|
|
# Installation automatique (configuration + repository)
|
|
./install
|
|
|
|
# Ou étape par étape
|
|
./install config # Génération configuration Restic
|
|
./install repo # Initialisation repository
|
|
```
|
|
|
|
3. **Installation d'un service**
|
|
```bash
|
|
sudo ./manage install <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
|
|
./manage list
|
|
```
|
|
|
|
## Utilisation
|
|
|
|
### Gestion des sauvegardes
|
|
```bash
|
|
# Lister les timers (configuration auto-sourcée)
|
|
./manage list
|
|
|
|
# Statut d'un service
|
|
./manage status paperless
|
|
|
|
# Lancer une sauvegarde manuelle
|
|
./manage run paperless
|
|
|
|
# Voir les logs
|
|
./manage logs paperless
|
|
|
|
# Services disponibles
|
|
./manage available
|
|
```
|
|
|
|
### Restauration
|
|
```bash
|
|
# Lister les snapshots
|
|
./manage snapshots paperless
|
|
|
|
# Restaurer en mode test
|
|
./manage restore paperless
|
|
|
|
# Restaurer en production
|
|
./manage restore-prod paperless
|
|
```
|
|
|
|
## Architecture
|
|
|
|
### Principes de conception
|
|
|
|
- **Interface unifiée** : Toutes les opérations via `./manage` et `./install`
|
|
- **Configuration auto-sourcée** : Plus besoin de sourcer manuellement
|
|
- **Scripts protégés** : Scripts dans `backup/` non exécutables directement
|
|
- **Sécurité** : Mots de passe générés automatiquement, permissions restreintes
|
|
|
|
### Composants
|
|
|
|
- **`./manage`** : Interface principale pour toutes les opérations de sauvegarde
|
|
- **`./install`** : Script d'installation consolidé (config + repository)
|
|
- **`backup.env`** : Configuration centralisée avec variables d'environnement
|
|
- **`backup/`** : Scripts internes appelés via `./manage` uniquement
|
|
|
|
### Développement
|
|
|
|
Les scripts dans `backup/` utilisent la variable `CALLED_FROM_MANAGE` pour empêcher l'exécution directe et garantir l'utilisation de l'interface unifiée. |