Compare commits

..

2 Commits

Author SHA1 Message Date
BeauTroll
df7dfe72a2 Migrate to Borgmatic 2.0 syntax without deprecations
- Replace deprecated 'prefix' with 'match_archives: sh:backup-*'
- Replace deprecated hooks (before_actions, after_backup, on_error) with new 'commands' syntax
- Use structured command format with name, when, and run fields
- Removes all deprecation warnings from borgmatic config validate

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-16 05:57:14 +01:00
BeauTroll
b215d8c325 add config validation support 2025-12-16 05:54:49 +01:00
4 changed files with 85 additions and 26 deletions

View File

@@ -21,7 +21,7 @@ install: ## Installe Borgmatic et configure le système
test-config: ## Valide la configuration Borgmatic
@echo "$(BLUE)Validation de la configuration...$(NC)"
@borgmatic config validate
@sudo borgmatic config validate
test-notifications: ## Teste les notifications ntfy
@echo "$(BLUE)Test des notifications ntfy...$(NC)"

View File

@@ -61,19 +61,30 @@ borg key export /path/to/repo backup-key.txt
## Tests
```bash
# 1. Tester les notifications
# 1. Valider la configuration
sudo borgmatic config validate
# 2. Tester les notifications
./scripts/test-notifications.sh
# 2. Vérifier la santé du système
# 3. Vérifier la santé du système
sudo ./scripts/healthcheck.sh
# 3. Test à vide (dry-run)
# 4. Test à vide (dry-run)
sudo borgmatic --dry-run --verbosity 2
# 4. Premier backup réel
# 5. Premier backup réel
sudo borgmatic --verbosity 1
```
### Explications des commandes de test
- **`borgmatic config validate`** : Vérifie la syntaxe YAML et la structure de config.yaml
- **`test-notifications.sh`** : Envoie des notifications de test via ntfy
- **`healthcheck.sh`** : Vérifie l'installation, la config, le timer, le repository
- **`--dry-run`** : Simule un backup complet sans rien modifier (teste la connexion au repo)
- **Sans `--dry-run`** : Exécute un vrai backup
## Vérifier le timer
```bash
@@ -140,19 +151,35 @@ borgmatic list # Devrait afficher vos anciennes archives
## En cas de problème
```bash
# Vérifier la santé
# 1. Valider d'abord la configuration
sudo borgmatic config validate
# 2. Vérifier la santé du système
sudo ./scripts/healthcheck.sh
# Voir les logs
# 3. Voir les logs
journalctl -u borgmatic.service -n 50
# Tester la configuration (avec dry-run)
borgmatic --dry-run
# 4. Tester avec dry-run
sudo borgmatic --dry-run --verbosity 2
# Mode verbeux
sudo borgmatic --verbosity 2
# 5. Mode debug (très verbeux)
sudo borgmatic --verbosity 2 --list --log-file-verbosity 2
```
### Erreurs courantes
**`repositories' is a required property`**
- Vérifiez que `repositories:` est présent dans config.yaml
- Vérifiez que `BORG_REPO` est défini dans .env
**`Additional properties are not allowed`**
- Vous utilisez une vieille structure de config pour Borgmatic 1.x
- Mettez à jour vers Borgmatic 2.0+ : `sudo pipx install borgmatic --force`
**`command not found: borgmatic`**
- Créez les liens symboliques : `sudo ln -sf /root/.local/bin/borgmatic /usr/local/bin/borgmatic`
## Support
Consultez le [README.md](README.md) pour plus de détails.

View File

@@ -152,13 +152,18 @@ borg key export /path/to/repo backup-key.txt
### Tester la configuration
```bash
# Valider la configuration (avec dry-run)
borgmatic --dry-run --verbosity 2
# 1. Valider la syntaxe du fichier de configuration
sudo borgmatic config validate
# Lister les fichiers qui seront sauvegardés
borgmatic list --json
# 2. Tester sans exécuter de backup (dry-run)
sudo borgmatic --dry-run --verbosity 2
# 3. Lister les fichiers qui seront sauvegardés
sudo borgmatic list --json
```
**Note :** `borgmatic config validate` vérifie uniquement la syntaxe YAML et la structure du fichier. Le dry-run teste la connexion au repository et simule un backup complet.
### Exécuter un backup manuel
```bash
@@ -270,6 +275,23 @@ Testez manuellement les notifications :
## Troubleshooting
### Valider la configuration
Avant tout, vérifiez que votre configuration est valide :
```bash
# Valider la syntaxe
sudo borgmatic config validate
# Si erreur, vérifier les détails
sudo borgmatic config validate --verbosity 2
```
Erreurs courantes :
- `repositories' is a required property` : Manque la section repositories
- `Additional properties are not allowed` : Propriété invalide pour cette version
- Erreurs YAML : Vérifier l'indentation (utiliser des espaces, pas des tabs)
### Le backup ne démarre pas
```bash

View File

@@ -51,8 +51,8 @@ keep_daily: 7
keep_weekly: 4
keep_monthly: 6
# Préfixe des archives
prefix: "backup-"
# Sélection des archives pour rétention (remplace 'prefix')
match_archives: "sh:backup-*"
# Vérifications d'intégrité
checks:
@@ -64,17 +64,27 @@ checks:
# Nombre d'archives à vérifier
check_last: 3
# Commandes/hooks pour notifications
before_actions:
- echo "Backup démarré"
# Commandes/hooks pour notifications (nouvelle syntaxe Borgmatic 2.0)
commands:
- name: "Notification de démarrage"
when:
- before_backup
run:
- echo "Backup démarré"
after_backup:
- echo "Exécution hook de succès"
- /etc/borgmatic/hooks/ntfy-success.sh "{archive_name}" "{stats}"
- name: "Notification de succès"
when:
- after_backup
run:
- echo "Exécution hook de succès"
- /etc/borgmatic/hooks/ntfy-success.sh "{archive_name}" "{stats}"
on_error:
- echo "Exécution hook d'erreur"
- /etc/borgmatic/hooks/ntfy-error.sh "{error}"
- name: "Notification d'erreur"
when:
- on_error
run:
- echo "Exécution hook d'erreur"
- /etc/borgmatic/hooks/ntfy-error.sh "{error}"
# Commandes PostgreSQL/MySQL si nécessaire
# postgresql_databases: