Compare commits

...

19 Commits

Author SHA1 Message Date
BeauTroll
14cbfab07b Add systemd compatibility and verbose logging to Seafile MySQL backup hook
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Enhance the Seafile MySQL dump hook with better debugging capabilities
and systemd service compatibility:
- Redirect all output to syslog for systemd journal integration
- Add Docker socket accessibility check before attempting dumps
- Add detailed logging at each step for troubleshooting
- Improve error handling with explicit exit codes
- Add context information (USER, PWD, HOME) for systemd debugging

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-13 07:54:06 +01:00
BeauTroll
0ae8cb9e0e Fix Seafile MySQL dump authentication by using root user
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Update the Seafile MySQL dump hook to use the root user by default
instead of seafile user, which resolves authentication issues. Add
SEAFILE_MYSQL_USER environment variable for user customization.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-09 13:45:10 +01:00
BeauTroll
9c29cc1bdc Improve Seafile MySQL dump hook with better error handling and debugging
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Add comprehensive validation and error messages to the Seafile MySQL backup hook:
- Add timeout (5min) to prevent mysqldump from hanging indefinitely
- Validate SEAFILE_DB_PASSWORD is set before attempting dump
- Verify Docker container exists and is running before execution
- Fix file verification bug (check correct output filename)
- Add detailed logging for easier troubleshooting
- Use set -e for fail-fast behavior

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-09 13:37:30 +01:00
BeauTroll
671347b39d add seafile mysql dump hook
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
2026-01-09 00:19:11 +01:00
BeauTroll
c8d62e79dc Add comprehensive restore testing documentation
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Create detailed guide for testing backup restoration at three levels:
quick checks, service restoration, and full disaster recovery.

Changes:
- Add docs/RESTORE-TESTING.md with complete testing procedures
- Include 3 testing levels (monthly, quarterly, semi-annual)
- Document common restoration scenarios
- Provide troubleshooting guides and checklists
- Add RTO/RPO measurement guidelines
- Include report templates for each test level

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 18:09:03 +01:00
BeauTroll
20a4364fd6 Improve error handling in test-notifications script
Fix permission error handling by checking file readability instead of
just existence, and provide clearer error messages with solutions.

Changes:
- Use -r flag instead of -f to check if .env is readable
- Add helpful error message with multiple solutions
- Guide users to either use sudo or create local .env file

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 17:40:10 +01:00
BeauTroll
ef82bca68e Add Uptime Kuma testing to test-notifications script
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Extend notification testing script to include Uptime Kuma push monitor
tests alongside existing ntfy tests.

Changes:
- Add 3 Uptime Kuma test scenarios (up, down, up)
- Gracefully skip Uptime Kuma tests if not configured
- Update script description to include Uptime Kuma
- Improve output formatting with separate sections

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 17:37:40 +01:00
BeauTroll
96cb54d1c6 Fix install.sh to copy all hook scripts automatically
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Update hook installation to use wildcard pattern instead of hardcoded
file names, ensuring all current and future hooks are copied.

Changes:
- Replace individual cp commands with cp hooks/*.sh pattern
- Automatically includes ntfy and uptime-kuma hooks
- More maintainable for future hook additions

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 17:34:46 +01:00
BeauTroll
21355eceff Add Uptime Kuma monitoring integration with dedicated hooks
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Implement Uptime Kuma Push Monitor support with separate hook files
following separation of concerns principle.

Changes:
- Add UPTIME_KUMA_PUSH_URL to .env.example
- Create dedicated uptime-kuma-success.sh hook
- Create dedicated uptime-kuma-error.sh hook
- Update config.yaml to call both ntfy and Uptime Kuma hooks
- Each notification service has its own file for modularity

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 17:26:48 +01:00
BeauTroll
07a98d5617 Fix duplicate output in disk-usage script with awk
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Replace grep-based parsing with awk to properly capture header and data
lines without duplicates.

Changes:
- Use awk to capture header line (Original/Compressed/Deduplicated size)
- Print header followed by matching "All archives" line with sizes
- Exit immediately after first match to prevent duplicates

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 16:09:56 +01:00
BeauTroll
b816e25caa Add column headers to disk-usage output
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Include the column headers (Original size, Compressed size, Deduplicated size)
in the disk-usage output for better readability.

Changes:
- Use grep -B1 to capture header line before "All archives"
- Display both header and data lines

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 16:07:51 +01:00
BeauTroll
9a5ea36901 Refactor disk-usage logic into dedicated script
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Move disk-usage functionality from Makefile to a dedicated shell script
for better maintainability and consistency with other scripts.

Changes:
- Create scripts/disk-usage.sh with all disk usage logic
- Simplify Makefile disk-usage target to call the script
- Add environment loading and color formatting to script
- Fix duplicate output by adding head -1 to grep chain

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 16:05:58 +01:00
BeauTroll
636f5987c7 Fix disk-usage to show size stats instead of chunk counts
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Filter borgmatic info output to show the "All archives" line containing
GB sizes instead of the chunk statistics line.

Changes:
- Add grep filter for "GB" to capture size statistics
- Avoid displaying chunk counts which appeared in wrong section

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 16:02:37 +01:00
BeauTroll
1afde7afc3 Show all archives stats instead of last archive in disk-usage
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Fix disk-usage command to display cumulative statistics for all archives
instead of just the last backup archive.

Changes:
- Target "All archives" section instead of "This archive"
- Show total deduplicated size across all backups
- Clarify label to indicate cumulative statistics

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 16:00:46 +01:00
BeauTroll
9b10a325dc Fix disk-usage command to handle SSH URLs with ports correctly
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Fix the disk-usage make target to properly parse SSH URLs containing ports
and display repository statistics correctly.

Changes:
- Simplify Borg statistics parsing to show actual values
- Fix SSH connection to handle custom ports (e.g., port 23)
- Extract user@host and port separately from BORG_REPO URL
- Use ssh -p PORT syntax instead of incorrect host:port format

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 15:48:27 +01:00
BeauTroll
cecc224dea Add disk-usage command to monitor backup server storage
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Add new make disk-usage command to display repository statistics and remote
server disk space. This helps monitor storage usage and plan capacity.

Changes:
- Add disk-usage target to display Borg repository statistics
- Show original, compressed, and deduplicated sizes
- Display free disk space on remote backup server via SSH
- Update .PHONY declaration with new target

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 15:43:12 +01:00
BeauTroll
6f968f73c4 Show backup size instead of repository in success notifications
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Replace repository path with backup size in ntfy success notifications to
provide more useful information about backup completion.

Changes:
- Add backup size retrieval using borgmatic info command
- Display original size in notification instead of repository path
- Fallback to "taille inconnue" if size cannot be determined

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 15:38:24 +01:00
BeauTroll
9c03ebf8e2 Exclude backup directories and improve YAML formatting
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Add exclusion patterns for Nextcloud and Gitea backup directories to avoid
backing up redundant data. Also normalize YAML indentation to 2 spaces for
consistency.

Changes:
- Exclude /opt/nextcloud/backups from backups
- Exclude /opt/gitea/backups from backups
- Add commented suggestions for preview and updater exclusions
- Normalize YAML indentation from 4 spaces to 2 spaces

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-17 20:40:07 +01:00
BeauTroll
b2beeb3334 Fix ntfy notification hooks to use Borgmatic 2.0 environment variables
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Replace deprecated argument-based parameter passing with environment variables
and dynamic data retrieval for archive names and error messages.

Changes:
- Remove "{archive_name}" and "{error}" placeholders from config.yaml
- Update ntfy-success.sh to retrieve archive name via borgmatic list
- Update ntfy-error.sh to extract error messages from systemd logs
- Add repository information to both notification types

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-17 06:42:14 +01:00
12 changed files with 1072 additions and 59 deletions

View File

@@ -29,6 +29,25 @@ NTFY_URL=https://ntfy.sh/your-topic-name
# Laisser vide si pas d'authentification
NTFY_USER=username:password
# ============================================
# MONITORING UPTIME KUMA
# ============================================
# URL du Push Monitor Uptime Kuma
# Obtenue depuis Uptime Kuma > Add New Monitor > Type: Push
UPTIME_KUMA_PUSH_URL=http://uptime-kuma:3001/api/push/YOUR_KEY_HERE
# ============================================
# BASES DE DONNÉES
# ============================================
# Mot de passe MySQL pour Seafile (généralement MYSQL_ROOT_PASSWORD)
SEAFILE_DB_PASSWORD=your-seafile-mysql-root-password
# Utilisateur MySQL pour les dumps (par défaut: root)
# Décommenter et modifier si vous utilisez un autre utilisateur
# SEAFILE_MYSQL_USER=seafile
# ============================================
# OPTIONS AVANCÉES
# ============================================

View File

@@ -1,7 +1,7 @@
# Makefile pour Borgmatic - Agence66
# Usage: make [commande]
.PHONY: help install test backup list restore healthcheck logs status clean
.PHONY: help install test backup list restore healthcheck logs status clean disk-usage
# Couleurs pour l'affichage
BLUE := \033[0;34m
@@ -55,6 +55,9 @@ info: ## Affiche les informations sur le repository
@echo "$(BLUE)Informations sur le repository:$(NC)"
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic info'
disk-usage: ## Affiche l'espace disque utilisé et libre sur le serveur de backup
@sudo ./scripts/disk-usage.sh
restore: ## Lance le script de restauration interactive
@echo "$(BLUE)Restauration interactive...$(NC)"
sudo ./scripts/restore.sh

View File

@@ -5,34 +5,40 @@
# Repository Borg - utilise la variable d'environnement
repositories:
- path: "${BORG_REPO}"
label: production
- path: "${BORG_REPO}"
label: production
# Chemins sources à sauvegarder
source_directories:
- /var/www
- /srv/minecraftserver
- /srv/reddiscordbot
- /srv/waltercoiffure
- /etc
- /opt/nextcloud
- /opt/traefik
- /opt/n8n
- /opt/portainer
- /opt/uptime-kuma
- /opt/vaultwarden
- /opt/mailcow-dockerized
- /opt/netdata
- /opt/gitea
- /home
- /var/www
- /srv/minecraftserver
- /srv/reddiscordbot
- /srv/waltercoiffure
- /etc
- /opt/nextcloud
- /opt/traefik
- /opt/n8n
- /opt/portainer
- /opt/uptime-kuma
- /opt/vaultwarden
- /opt/mailcow-dockerized
- /opt/netdata
- /opt/gitea
- /home
# Patterns d'exclusion
exclude_patterns:
- "*.log"
- "*/cache/*"
- "*/tmp/*"
- "**/__pycache__"
- "*/node_modules/*"
- "*.log"
- "*/cache/*"
- "*/tmp/*"
- "**/__pycache__"
- "*/node_modules/*"
- "/opt/nextcloud/backups"
#- "/opt/nextcloud/data/appdata_*/preview/*" # Miniatures d'images
#- "/opt/nextcloud/updater-*" # Fichiers de mise à jour
- "/opt/gitea/backups"
# Un seul système de fichiers
one_file_system: false
@@ -56,32 +62,34 @@ match_archives: "sh:backup-*"
# Vérifications d'intégrité
checks:
- name: repository
frequency: 2 weeks
- name: archives
frequency: 1 month
- name: repository
frequency: 2 weeks
- name: archives
frequency: 1 month
# Nombre d'archives à vérifier
check_last: 3
# Hooks pour notifications (syntaxe Borgmatic 2.0)
commands:
- before: action
when: [create]
run:
- echo "Backup démarré"
- before: action
when: [create]
run:
- echo "Backup démarré"
- /etc/borgmatic/hooks/seafile-docker-mysql-backup.sh
- after: action
when: [create]
run:
- echo "Exécution hook de succès"
- /etc/borgmatic/hooks/ntfy-success.sh "{archive_name}" "{stats}"
- after: error
run:
- echo "Exécution hook d'erreur"
- /etc/borgmatic/hooks/ntfy-error.sh "{error}"
- after: action
when: [create]
run:
- echo "Exécution hooks de succès"
- /etc/borgmatic/hooks/ntfy-success.sh
- /etc/borgmatic/hooks/uptime-kuma-success.sh
- after: error
run:
- echo "Exécution hooks d'erreur"
- /etc/borgmatic/hooks/ntfy-error.sh
- /etc/borgmatic/hooks/uptime-kuma-error.sh
# Commandes PostgreSQL/MySQL si nécessaire
# postgresql_databases:
# - name: all

714
docs/RESTORE-TESTING.md Normal file
View File

@@ -0,0 +1,714 @@
# Guide de test de restauration Borgmatic
> **"Un backup non testé n'est pas un backup"**
Ce guide décrit comment tester vos backups Borgmatic pour garantir que vos données sont restaurables en cas de sinistre.
## Table des matières
- [Pourquoi tester ?](#pourquoi-tester)
- [Pré-requis](#pré-requis)
- [Niveau 1 : Test rapide (mensuel)](#niveau-1--test-rapide-mensuel)
- [Niveau 2 : Test de service (trimestriel)](#niveau-2--test-de-service-trimestriel)
- [Niveau 3 : Disaster Recovery complet (semestriel)](#niveau-3--disaster-recovery-complet-semestriel)
- [Scénarios de restauration courants](#scénarios-de-restauration-courants)
- [Checklist de vérification](#checklist-de-vérification)
- [Troubleshooting](#troubleshooting)
---
## Pourquoi tester ?
### Risques sans test de restauration
- ❌ Backup corrompu découvert trop tard
- ❌ Passphrase incorrecte ou perdue
- ❌ Clés SSH manquantes ou expirées
- ❌ Fichiers critiques exclus par erreur
- ❌ Permissions/ownership incorrects
- ❌ Temps de restauration inconnu (RTO)
- ❌ Procédure non documentée
### Bénéfices des tests réguliers
- ✅ Confiance totale dans vos backups
- ✅ Procédure éprouvée et documentée
- ✅ Temps de restauration mesuré
- ✅ Détection précoce des problèmes
- ✅ Équipe formée en conditions réelles
---
## Pré-requis
### Informations nécessaires
Assurez-vous d'avoir accès à :
```bash
# Variables d'environnement
BORG_REPO=ssh://USER@IP:PORT/./backups
BORG_PASSPHRASE=votre-passphrase-sécurisée
# Clés SSH
~/.ssh/id_rsa (ou clé configurée pour le serveur de backup)
```
### Vérifications préliminaires
```bash
# 1. Vérifier la connexion au repository
make info
# 2. Lister les archives disponibles
make list
# 3. Vérifier l'intégrité du repository
make check
```
---
## Niveau 1 : Test rapide (mensuel)
**Durée estimée :** 5-10 minutes
**Fréquence recommandée :** Tous les mois
**Objectif :** Vérifier que la restauration fonctionne
### Procédure
#### 1. Créer un environnement de test
```bash
# Créer un dossier de test avec horodatage
TEST_DIR="/tmp/restore-test-$(date +%Y%m%d-%H%M)"
mkdir -p "$TEST_DIR"
cd "$TEST_DIR"
```
#### 2. Restaurer quelques fichiers critiques
```bash
# Restaurer la configuration Borgmatic
borgmatic extract \
--archive latest \
--path /etc/borgmatic/config.yaml \
--destination "$TEST_DIR/"
# Restaurer un fichier Nextcloud
borgmatic extract \
--archive latest \
--path /opt/nextcloud/config/config.php \
--destination "$TEST_DIR/"
# Restaurer un fichier de configuration système
borgmatic extract \
--archive latest \
--path /etc/nginx/nginx.conf \
--destination "$TEST_DIR/"
```
#### 3. Vérifier les fichiers restaurés
```bash
# Vérifier que les fichiers existent
ls -lh "$TEST_DIR/etc/borgmatic/"
ls -lh "$TEST_DIR/opt/nextcloud/config/"
# Comparer avec l'original (si toujours accessible)
diff /etc/borgmatic/config.yaml "$TEST_DIR/etc/borgmatic/config.yaml"
# Vérifier le contenu
cat "$TEST_DIR/etc/borgmatic/config.yaml"
```
#### 4. Nettoyer
```bash
# Supprimer le dossier de test
rm -rf "$TEST_DIR"
echo "✅ Test rapide terminé avec succès"
```
### Checklist de validation
- [ ] Les fichiers ont été restaurés sans erreur
- [ ] Le contenu des fichiers est correct
- [ ] Les permissions semblent correctes
- [ ] Aucun message d'erreur dans les logs
---
## Niveau 2 : Test de service (trimestriel)
**Durée estimée :** 30-60 minutes
**Fréquence recommandée :** Tous les 3 mois
**Objectif :** Vérifier la restauration complète d'un service
### Scénario : Restaurer Nextcloud complet
#### 1. Préparer l'environnement
```bash
TEST_DIR="/tmp/restore-nextcloud-$(date +%Y%m%d)"
mkdir -p "$TEST_DIR"
```
#### 2. Restaurer Nextcloud
```bash
# Restaurer tous les fichiers Nextcloud
borgmatic extract \
--archive latest \
--path /opt/nextcloud \
--destination "$TEST_DIR/"
# Chronométrer la restauration
time borgmatic extract \
--archive latest \
--path /opt/nextcloud \
--destination "$TEST_DIR/"
```
#### 3. Vérifier la restauration
```bash
# Vérifier la taille totale
du -sh "$TEST_DIR/opt/nextcloud/"
# Comparer avec la production
du -sh /opt/nextcloud/
# Vérifier la structure
tree -L 2 "$TEST_DIR/opt/nextcloud/"
# Vérifier les fichiers de configuration
cat "$TEST_DIR/opt/nextcloud/config/config.php"
# Vérifier quelques fichiers utilisateurs
ls -lh "$TEST_DIR/opt/nextcloud/data/"
# Vérifier les permissions
ls -la "$TEST_DIR/opt/nextcloud/"
```
#### 4. Tests approfondis
```bash
# Compter les fichiers
find "$TEST_DIR/opt/nextcloud/" -type f | wc -l
find /opt/nextcloud/ -type f | wc -l
# Vérifier les bases de données (si incluses)
ls -lh "$TEST_DIR/opt/nextcloud/data/"*.db
# Tester l'intégrité de fichiers aléatoires
md5sum "$TEST_DIR/opt/nextcloud/data/user1/files/photo.jpg"
```
#### 5. Documenter les résultats
```bash
# Créer un rapport
cat > "$TEST_DIR/test-report.txt" <<EOF
Test de restauration Nextcloud
Date: $(date)
Archive: latest
Durée: [À REMPLIR]
Taille restaurée: $(du -sh "$TEST_DIR/opt/nextcloud/" | cut -f1)
Nombre de fichiers: $(find "$TEST_DIR/opt/nextcloud/" -type f | wc -l)
Statut: ✅ SUCCÈS / ❌ ÉCHEC
Notes: [VOS OBSERVATIONS]
EOF
cat "$TEST_DIR/test-report.txt"
```
### Autres services à tester
```bash
# Gitea
borgmatic extract --archive latest --path /opt/gitea --destination "$TEST_DIR/"
# Mailcow
borgmatic extract --archive latest --path /opt/mailcow-dockerized --destination "$TEST_DIR/"
# Configurations système
borgmatic extract --archive latest --path /etc --destination "$TEST_DIR/"
```
---
## Niveau 3 : Disaster Recovery complet (semestriel)
**Durée estimée :** 2-4 heures
**Fréquence recommandée :** Tous les 6 mois
**Objectif :** Simuler une catastrophe totale et restaurer sur un nouveau serveur
### Scénario : "Le serveur de production a brûlé"
#### Phase 1 : Préparation du nouveau serveur
**Option A : VM de test locale**
```bash
# Créer une VM Ubuntu/Debian avec les mêmes specs
# - RAM : même quantité que prod
# - Disque : au moins la taille de vos backups
# - Réseau : accès Internet
```
**Option B : Serveur de secours**
```bash
# Utiliser un serveur de backup/staging
# S'assurer qu'il est vierge ou sauvegardé
```
#### Phase 2 : Installation des bases
```bash
# 1. Mettre à jour le système
sudo apt update && sudo apt upgrade -y
# 2. Installer les dépendances de base
sudo apt install -y git curl wget vim
# 3. Cloner le repo de configuration
cd /opt
sudo git clone https://git.example.com/agence66-borgmatic.git borgmatic
cd borgmatic
# 4. Configurer les variables d'environnement
sudo cp .env.example /etc/borgmatic/.env
sudo nano /etc/borgmatic/.env
# Remplir : BORG_REPO, BORG_PASSPHRASE
# 5. Configurer les clés SSH
sudo mkdir -p /root/.ssh
sudo cp votre-cle-ssh /root/.ssh/id_rsa
sudo chmod 600 /root/.ssh/id_rsa
# 6. Installer Borgmatic
sudo ./install.sh
```
#### Phase 3 : Vérifier l'accès au repository
```bash
# Tester la connexion
sudo borgmatic list
# Lister les archives disponibles
sudo borgmatic list --archive all
# Choisir l'archive à restaurer (généralement la plus récente)
ARCHIVE_NAME="backup-20251218-0301"
```
#### Phase 4 : Restauration complète
**IMPORTANT : Chronométrez chaque étape pour mesurer votre RTO réel**
```bash
# Démarrer le chronomètre
START_TIME=$(date +%s)
# Restaurer TOUT
sudo borgmatic extract \
--archive "$ARCHIVE_NAME" \
--destination /tmp/full-restore/
# Calculer le temps écoulé
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
echo "Durée de restauration: $((DURATION / 60)) minutes"
```
#### Phase 5 : Reconstruction des services
```bash
# 1. Copier les fichiers restaurés vers leurs emplacements
sudo cp -a /tmp/full-restore/opt/* /opt/
sudo cp -a /tmp/full-restore/etc/* /etc/
sudo cp -a /tmp/full-restore/var/www/* /var/www/
# 2. Installer Docker et Docker Compose
sudo apt install -y docker.io docker-compose
# 3. Restaurer les configurations Docker
cd /opt/nextcloud && sudo docker-compose up -d
cd /opt/mailcow-dockerized && sudo docker-compose up -d
cd /opt/gitea && sudo docker-compose up -d
# 4. Vérifier les permissions
sudo chown -R www-data:www-data /var/www/
sudo chown -R 1000:1000 /opt/nextcloud/data/
# 5. Redémarrer les services
sudo systemctl restart nginx
sudo systemctl restart mysql
```
#### Phase 6 : Tests de validation
```bash
# 1. Vérifier que les services démarrent
docker ps -a
systemctl status nginx
systemctl status mysql
# 2. Tester l'accès web
curl -I http://localhost
curl -I http://localhost/nextcloud
# 3. Vérifier les bases de données
mysql -e "SHOW DATABASES;"
# 4. Tester un login utilisateur
# → Ouvrir le navigateur et tester Nextcloud, Mailcow, etc.
# 5. Vérifier les données
ls -lh /opt/nextcloud/data/
ls -lh /var/www/html/
```
#### Phase 7 : Documentation du processus
```bash
# Créer un rapport détaillé
cat > /tmp/disaster-recovery-report-$(date +%Y%m%d).txt <<EOF
==========================================================
RAPPORT DE TEST DISASTER RECOVERY
==========================================================
Date du test: $(date)
Serveur de test: [NOM/IP]
Archive utilisée: $ARCHIVE_NAME
CHRONOLOGIE
-----------
1. Préparation serveur: [DURÉE]
2. Installation bases: [DURÉE]
3. Restauration fichiers: $((DURATION / 60)) minutes
4. Reconstruction services: [DURÉE]
5. Validation: [DURÉE]
DURÉE TOTALE (RTO): [DURÉE TOTALE]
SERVICES TESTÉS
---------------
[ ] Nextcloud - Statut: ✅/❌
[ ] Mailcow - Statut: ✅/❌
[ ] Gitea - Statut: ✅/❌
[ ] Nginx - Statut: ✅/❌
[ ] Autres: [LISTE]
PROBLÈMES RENCONTRÉS
--------------------
1. [PROBLÈME 1]
Solution: [SOLUTION]
2. [PROBLÈME 2]
Solution: [SOLUTION]
AMÉLIORATIONS IDENTIFIÉES
--------------------------
1. [AMÉLIORATION 1]
2. [AMÉLIORATION 2]
LEÇONS APPRISES
---------------
1. [LEÇON 1]
2. [LEÇON 2]
PROCHAINES ACTIONS
------------------
[ ] Mettre à jour la documentation
[ ] Corriger les problèmes identifiés
[ ] Former l'équipe sur la procédure
[ ] Planifier le prochain test
VALIDATION
----------
Testé par: [NOM]
Validé par: [NOM]
Signature: _________________
EOF
cat /tmp/disaster-recovery-report-$(date +%Y%m%d).txt
```
---
## Scénarios de restauration courants
### 1. Fichier supprimé accidentellement
```bash
# Lister les archives contenant le fichier
borgmatic list --path /opt/nextcloud/data/user/important.pdf
# Restaurer depuis une archive spécifique
borgmatic extract \
--archive backup-20251215-0301 \
--path /opt/nextcloud/data/user/important.pdf \
--destination /tmp/restore/
# Copier le fichier restauré
cp /tmp/restore/opt/nextcloud/data/user/important.pdf /opt/nextcloud/data/user/
```
### 2. Base de données corrompue
```bash
# Restaurer le dump de base de données
borgmatic extract \
--archive latest \
--path /opt/mailcow-dockerized/backup/mysql \
--destination /tmp/restore/
# Importer la base de données
mysql < /tmp/restore/opt/mailcow-dockerized/backup/mysql/dump.sql
```
### 3. Configuration cassée
```bash
# Restaurer l'ancienne configuration
borgmatic extract \
--archive backup-20251210-0301 \
--path /etc/nginx/nginx.conf \
--destination /tmp/restore/
# Comparer et restaurer
diff /etc/nginx/nginx.conf /tmp/restore/etc/nginx/nginx.conf
sudo cp /tmp/restore/etc/nginx/nginx.conf /etc/nginx/nginx.conf
sudo systemctl restart nginx
```
### 4. Rollback complet d'un service
```bash
# Arrêter le service
cd /opt/nextcloud && docker-compose down
# Sauvegarder l'état actuel
mv /opt/nextcloud /opt/nextcloud.broken
# Restaurer depuis une archive antérieure
borgmatic extract \
--archive backup-20251201-0301 \
--path /opt/nextcloud \
--destination /opt/
# Redémarrer
cd /opt/nextcloud && docker-compose up -d
```
---
## Checklist de vérification
### Avant la restauration
- [ ] Archive de backup identifiée
- [ ] Espace disque suffisant (au moins 2x la taille du backup)
- [ ] BORG_PASSPHRASE disponible
- [ ] Clés SSH configurées
- [ ] Accès au repository Borg validé
- [ ] Services arrêtés si restauration en production
- [ ] Backup de l'état actuel effectué
### Pendant la restauration
- [ ] Chronométrage des étapes
- [ ] Logs de restauration sauvegardés
- [ ] Vérification des erreurs en temps réel
- [ ] Documentation des problèmes rencontrés
### Après la restauration
- [ ] Fichiers/dossiers présents
- [ ] Permissions correctes
- [ ] Ownership correct (user:group)
- [ ] Taille des données cohérente
- [ ] Services démarrent correctement
- [ ] Accès web fonctionnel
- [ ] Bases de données accessibles
- [ ] Tests fonctionnels réussis
- [ ] Logs vérifiés
- [ ] Rapport de test complété
---
## Troubleshooting
### Erreur : "Permission denied"
```bash
# Solution : Utiliser sudo
sudo borgmatic extract ...
# Vérifier les permissions du repository
ls -la /etc/borgmatic/
```
### Erreur : "Repository not found"
```bash
# Vérifier BORG_REPO
echo $BORG_REPO
# Tester la connexion SSH
ssh -p 23 u516154@u516154.your-storagebox.de
# Vérifier la clé SSH
ssh-add -l
```
### Erreur : "Passphrase incorrect"
```bash
# Vérifier BORG_PASSPHRASE
echo $BORG_PASSPHRASE
# Charger depuis .env
source /etc/borgmatic/.env
```
### Restauration très lente
```bash
# Utiliser des options de performance
borgmatic extract --archive latest --path /opt/nextcloud --threads 4
# Vérifier la bande passante réseau
iftop
nload
```
### Fichiers manquants après restauration
```bash
# Vérifier qu'ils n'étaient pas exclus
grep -r "exclude" /etc/borgmatic/config.yaml
# Lister tous les fichiers de l'archive
borgmatic list --archive latest --short > /tmp/archive-files.txt
grep "nextcloud" /tmp/archive-files.txt
```
### Permissions incorrectes
```bash
# Restaurer les permissions originales
sudo chown -R www-data:www-data /opt/nextcloud/data/
sudo chmod -R 755 /opt/nextcloud/
```
---
## Bonnes pratiques
### 1. Planification des tests
Créez un calendrier de tests :
```
Janvier : Test rapide
Février : Test rapide
Mars : Test rapide + Test service (Nextcloud)
Avril : Test rapide
Mai : Test rapide
Juin : Test rapide + Test service (Mailcow) + DR complet
Juillet : Test rapide
...
```
### 2. Documentation continue
Après CHAQUE test :
- Mettre à jour ce document avec les leçons apprises
- Noter les durées réelles
- Documenter les problèmes et solutions
- Partager avec l'équipe
### 3. Automatisation
Créer des scripts pour les tests fréquents :
```bash
# Script de test rapide automatisé
./scripts/test-restore-quick.sh
# Script de rapport automatique
./scripts/generate-restore-report.sh
```
### 4. Formation de l'équipe
- Faire tourner les personnes qui effectuent les tests
- Documenter la procédure comme si vous la lisiez pour la première fois
- Simuler des pannes sans prévenir (test surprise)
### 5. Amélioration continue
À chaque test, posez-vous :
- Qu'est-ce qui pourrait être plus rapide ?
- Qu'est-ce qui manque dans la documentation ?
- Quels fichiers critiques ne sont pas backupés ?
- Comment réduire le RTO (temps de restauration) ?
---
## Métriques importantes
### RTO (Recovery Time Objective)
**Temps maximum acceptable pour restaurer le service**
Mesurez lors de vos tests :
- Restauration fichiers uniquement : **\_** minutes
- Restauration + redémarrage services : **\_** minutes
- Disaster Recovery complet : **\_** heures
### RPO (Recovery Point Objective)
**Quantité de données qu'on peut accepter de perdre**
Avec backup quotidien à 3h :
- RPO : Maximum 24 heures de données perdues
Si critique, envisager :
- Backups plus fréquents (2x/jour)
- Réplication en temps réel
- Snapshots supplémentaires
---
## Conclusion
**Un test de restauration régulier est la SEULE façon de garantir que vos backups fonctionnent.**
N'attendez pas la catastrophe pour découvrir que vos backups sont inutilisables.
### Prochaines étapes
1. [ ] Planifier votre premier test rapide (cette semaine)
2. [ ] Calendrier de tests pour l'année
3. [ ] Former au moins une autre personne à la procédure
4. [ ] Automatiser les tests simples
5. [ ] Documenter votre RTO/RPO réel
---
**Date de dernière mise à jour :** 2025-12-18
**Version :** 1.0
**Mainteneur :** Agence66

View File

@@ -1,7 +1,7 @@
#!/bin/bash
#
# Hook Borgmatic - Notification d'erreur via ntfy
# Arguments: $1 = error message
# Borgmatic 2.0 utilise des variables d'environnement
#
# Charger les variables d'environnement
@@ -9,7 +9,12 @@ if [ -f /etc/borgmatic/.env ]; then
source /etc/borgmatic/.env
fi
ERROR_MSG="${1:-Erreur inconnue}"
# Récupérer les dernières lignes d'erreur depuis les logs
ERROR_MSG=$(journalctl -u borgmatic.service -n 10 --no-pager | tail -5 | sed 's/^.*borgmatic: //')
if [ -z "$ERROR_MSG" ]; then
ERROR_MSG="Erreur inconnue - vérifiez les logs"
fi
# Envoyer notification d'erreur
curl -s -u "$NTFY_USER" \
@@ -19,6 +24,7 @@ curl -s -u "$NTFY_USER" \
-d "Le backup a échoué !
Erreur: ${ERROR_MSG}
Date: $(date '+%Y-%m-%d %H:%M:%S')
Repository: ${BORG_REPO}
Vérifiez les logs: journalctl -u borgmatic.service -n 50" \
"$NTFY_URL"

View File

@@ -1,7 +1,7 @@
#!/bin/bash
#
# Hook Borgmatic - Notification de succès via ntfy
# Arguments: $1 = archive_name, $2 = stats
# Borgmatic 2.0 utilise des variables d'environnement
#
# Charger les variables d'environnement
@@ -9,12 +9,18 @@ if [ -f /etc/borgmatic/.env ]; then
source /etc/borgmatic/.env
fi
ARCHIVE_NAME="${1:-inconnu}"
STATS="${2:-}"
# Récupérer le nom de la dernière archive créée
# Borgmatic 2.0 expose BORG_REPO et autres variables d'environnement
ARCHIVE_NAME=$(borgmatic list --last 1 --short 2>/dev/null | tail -1)
if [ -z "$ARCHIVE_NAME" ]; then
ARCHIVE_NAME="dernière archive"
fi
# Extraire la taille depuis les stats si disponible
# Borgmatic passe les stats en JSON, on peut parser ou utiliser directement
SIZE="voir logs pour détails"
# Récupérer la taille du backup
BACKUP_SIZE=$(borgmatic info --archive "$ARCHIVE_NAME" 2>/dev/null | grep -E "Original size|This archive" | head -1 | awk '{print $(NF-1), $NF}')
if [ -z "$BACKUP_SIZE" ]; then
BACKUP_SIZE="taille inconnue"
fi
# Envoyer notification de succès
curl -s -u "$NTFY_USER" \
@@ -23,7 +29,8 @@ curl -s -u "$NTFY_USER" \
-H "Tags: white_check_mark,backup" \
-d "Backup terminé avec succès.
Archive: ${ARCHIVE_NAME}
Date: $(date '+%Y-%m-%d %H:%M:%S')" \
Date: $(date '+%Y-%m-%d %H:%M:%S')
Taille: ${BACKUP_SIZE}" \
"$NTFY_URL"
echo "Notification de succès envoyée à ntfy"

View File

@@ -0,0 +1,91 @@
#!/bin/bash
# Hook Borgmatic - Dump MySQL Seafile dockerisé avant backup
set -e # Arrêter en cas d'erreur
BACKUP_DIR="/opt/seafile/backups/mysql"
DATE=$(date +%Y%m%d-%H%M)
SEAFILE_CONTAINER="seafile" # Nom de votre conteneur Seafile
MYSQL_CONTAINER="seafile-mysql" # Ou le nom de votre conteneur MySQL
# Log pour debug systemd
exec 1> >(logger -t seafile-backup -p user.info)
exec 2> >(logger -t seafile-backup -p user.error)
echo "[$(date)] Démarrage dump MySQL Seafile..."
echo "Contexte: USER=$USER, PWD=$PWD, HOME=$HOME"
# Créer le répertoire de backup
mkdir -p "$BACKUP_DIR"
echo "✓ Répertoire de backup: $BACKUP_DIR"
# Charger les identifiants depuis .env
if [ -f /etc/borgmatic/.env ]; then
source /etc/borgmatic/.env
echo "✓ Variables chargées depuis /etc/borgmatic/.env"
else
echo "⚠️ /etc/borgmatic/.env non trouvé"
fi
# Utilisateur MySQL (par défaut root, configurable via .env)
MYSQL_USER="${SEAFILE_MYSQL_USER:-root}"
# Vérifier que le mot de passe est défini
if [ -z "$SEAFILE_DB_PASSWORD" ]; then
echo "❌ SEAFILE_DB_PASSWORD n'est pas défini dans /etc/borgmatic/.env"
exit 1
fi
echo "✓ Utilisateur MySQL: $MYSQL_USER"
echo "✓ Mot de passe MySQL défini"
# Vérifier l'accès à Docker
echo "Test accès Docker..."
if ! docker info >/dev/null 2>&1; then
echo "❌ Impossible d'accéder à Docker (socket /var/run/docker.sock)"
exit 1
fi
echo "✓ Docker accessible"
# Vérifier que le conteneur existe et tourne
echo "Recherche du conteneur $MYSQL_CONTAINER..."
if ! docker ps --format '{{.Names}}' | grep -q "^${MYSQL_CONTAINER}$"; then
echo "❌ Conteneur $MYSQL_CONTAINER non trouvé ou arrêté"
echo "Conteneurs disponibles:"
docker ps --format " - {{.Names}}"
exit 1
fi
echo "✓ Conteneur $MYSQL_CONTAINER trouvé"
# Dump unique avec toutes les bases
DUMP_FILE="$BACKUP_DIR/seafile-all-$DATE.sql"
echo "→ Lancement du dump MySQL vers: $DUMP_FILE"
echo "→ Commande: docker exec $MYSQL_CONTAINER mysqldump -u $MYSQL_USER ..."
# Utiliser une approche sans redirection 2>&1 qui peut bloquer
set +e # Désactiver temporairement set -e pour capturer le code de sortie
timeout 300 docker exec "$MYSQL_CONTAINER" mysqldump \
-u "$MYSQL_USER" -p"${SEAFILE_DB_PASSWORD}" \
--single-transaction --quick --databases \
ccnet_db seafile_db seahub_db > "$DUMP_FILE" 2>&1
DUMP_EXIT_CODE=$?
set -e
echo "→ Code de sortie mysqldump: $DUMP_EXIT_CODE"
if [ $DUMP_EXIT_CODE -eq 0 ] && [ -f "$DUMP_FILE" ] && [ -s "$DUMP_FILE" ]; then
SIZE=$(du -h "$DUMP_FILE" | cut -f1)
echo "✓ Dump créé: seafile-all-$DATE.sql ($SIZE)"
else
echo "❌ Échec du dump (code sortie: $DUMP_EXIT_CODE)"
[ -f "$DUMP_FILE" ] && echo "Taille fichier: $(stat -f %z "$DUMP_FILE" 2>/dev/null || stat -c %s "$DUMP_FILE") bytes"
exit 1
fi
# Nettoyer les anciens dumps (garder 7 jours)
DELETED=$(find "$BACKUP_DIR" -name "*.sql" -mtime +7 -delete -print | wc -l)
if [ "$DELETED" -gt 0 ]; then
echo "🗑️ $DELETED ancien(s) dump(s) supprimé(s)"
fi
echo "[$(date)] ✅ Dump MySQL Seafile terminé avec succès"
exit 0

28
hooks/uptime-kuma-error.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
#
# Hook Borgmatic - Ping Uptime Kuma en cas d'erreur
# Borgmatic 2.0 utilise des variables d'environnement
#
# Charger les variables d'environnement
if [ -f /etc/borgmatic/.env ]; then
source /etc/borgmatic/.env
fi
# Vérifier que l'URL Uptime Kuma est configurée
if [ -z "$UPTIME_KUMA_PUSH_URL" ]; then
echo "UPTIME_KUMA_PUSH_URL non configuré, ping ignoré"
exit 0
fi
# Ping Uptime Kuma avec status=down
curl -s "${UPTIME_KUMA_PUSH_URL}?status=down&msg=Backup%20failed&ping=" > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Ping Uptime Kuma envoyé (error)"
else
echo "Erreur lors du ping Uptime Kuma"
exit 1
fi
exit 0

28
hooks/uptime-kuma-success.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
#
# Hook Borgmatic - Ping Uptime Kuma en cas de succès
# Borgmatic 2.0 utilise des variables d'environnement
#
# Charger les variables d'environnement
if [ -f /etc/borgmatic/.env ]; then
source /etc/borgmatic/.env
fi
# Vérifier que l'URL Uptime Kuma est configurée
if [ -z "$UPTIME_KUMA_PUSH_URL" ]; then
echo "UPTIME_KUMA_PUSH_URL non configuré, ping ignoré"
exit 0
fi
# Ping Uptime Kuma avec status=up
curl -s "${UPTIME_KUMA_PUSH_URL}?status=up&msg=Backup%20successful&ping=" > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Ping Uptime Kuma envoyé (success)"
else
echo "Erreur lors du ping Uptime Kuma"
exit 1
fi
exit 0

View File

@@ -127,9 +127,8 @@ echo -e "${YELLOW}📋 Copie des fichiers de configuration...${NC}"
cp config.yaml /etc/borgmatic/config.yaml
chmod 600 /etc/borgmatic/config.yaml
# Scripts de hooks
cp hooks/ntfy-success.sh /etc/borgmatic/hooks/
cp hooks/ntfy-error.sh /etc/borgmatic/hooks/
# Scripts de hooks - copier tous les fichiers .sh
cp hooks/*.sh /etc/borgmatic/hooks/
chmod +x /etc/borgmatic/hooks/*.sh
echo -e "${GREEN}✅ Fichiers de configuration copiés${NC}"

43
scripts/disk-usage.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
#
# Script d'affichage de l'espace disque du serveur de backup
# Usage: ./disk-usage.sh
#
set -e
# Couleurs
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Charger et exporter les variables d'environnement
if [ -f /etc/borgmatic/.env ]; then
set -a
source /etc/borgmatic/.env
set +a
elif [ -f .env ]; then
set -a
source .env
set +a
fi
echo -e "${BLUE}Espace disque sur le serveur de backup:${NC}"
echo ""
# Statistiques du repository Borg
echo -e "${YELLOW}Espace utilisé par le repository Borg (toutes archives):${NC}"
borgmatic info 2>/dev/null | awk '/Original size.*Compressed size.*Deduplicated size/{header=$0; next} /All archives:.*[GT]B/{if(header) print header; print; exit}'
echo ""
# Espace libre sur le serveur distant
echo -e "${YELLOW}Espace libre sur le serveur distant:${NC}"
USER_HOST=$(echo $BORG_REPO | sed "s|ssh://||" | sed "s|:.*||")
PORT=$(echo $BORG_REPO | grep -o ":[0-9]*/" | sed "s|[:/]||g")
if [ -n "$PORT" ]; then
ssh -p $PORT $USER_HOST "df -h ~/ | tail -1"
else
ssh $USER_HOST "df -h ~/ | tail -1"
fi

View File

@@ -1,6 +1,6 @@
#!/bin/bash
#
# Script de test des notifications ntfy
# Script de test des notifications (ntfy et Uptime Kuma)
# Usage: ./test-notifications.sh
#
@@ -12,13 +12,18 @@ BLUE='\033[0;34m'
NC='\033[0m'
# Charger les variables d'environnement
if [ -f /etc/borgmatic/.env ]; then
if [ -r /etc/borgmatic/.env ]; then
source /etc/borgmatic/.env
elif [ -f .env ]; then
elif [ -r .env ]; then
source .env
else
echo -e "${RED}❌ Fichier .env non trouvé${NC}"
echo "Créez un fichier .env avec NTFY_URL et NTFY_USER"
echo -e "${RED}❌ Fichier .env non trouvé ou non lisible${NC}"
echo ""
echo "Solutions:"
echo " 1. Exécutez ce script avec sudo"
echo " 2. Créez un fichier .env local dans le dossier du projet"
echo " cp .env.example .env && nano .env"
echo ""
exit 1
fi
@@ -98,13 +103,75 @@ else
exit 1
fi
echo ""
echo -e "${BLUE}==================================================${NC}"
echo -e "${BLUE}Test des notifications Uptime Kuma${NC}"
echo -e "${BLUE}==================================================${NC}"
echo ""
# Vérifier si Uptime Kuma est configuré
if [ -z "$UPTIME_KUMA_PUSH_URL" ]; then
echo -e "${YELLOW}⚠️ UPTIME_KUMA_PUSH_URL non configuré${NC}"
echo "Ignoré - configurez UPTIME_KUMA_PUSH_URL dans .env pour tester Uptime Kuma"
else
echo -e "${YELLOW}Configuration:${NC}"
echo " URL: ${UPTIME_KUMA_PUSH_URL}"
echo ""
# Test 4: Ping Uptime Kuma (succès)
echo -e "${YELLOW}📤 Test 4: Ping Uptime Kuma (status=up)...${NC}"
RESPONSE=$(curl -s -w "\n%{http_code}" "${UPTIME_KUMA_PUSH_URL}?status=up&msg=Test%20success&ping=")
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
if [ "$HTTP_CODE" -eq 200 ]; then
echo -e "${GREEN}✅ Ping Uptime Kuma (success) envoyé avec succès${NC}"
else
echo -e "${RED}❌ Échec (HTTP $HTTP_CODE)${NC}"
echo "$RESPONSE"
fi
sleep 2
# Test 5: Ping Uptime Kuma (erreur)
echo -e "${YELLOW}📤 Test 5: Ping Uptime Kuma (status=down)...${NC}"
RESPONSE=$(curl -s -w "\n%{http_code}" "${UPTIME_KUMA_PUSH_URL}?status=down&msg=Test%20error&ping=")
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
if [ "$HTTP_CODE" -eq 200 ]; then
echo -e "${GREEN}✅ Ping Uptime Kuma (error) envoyé avec succès${NC}"
else
echo -e "${RED}❌ Échec (HTTP $HTTP_CODE)${NC}"
fi
sleep 2
# Test 6: Remettre le statut à "up"
echo -e "${YELLOW}📤 Test 6: Remettre Uptime Kuma à up...${NC}"
RESPONSE=$(curl -s -w "\n%{http_code}" "${UPTIME_KUMA_PUSH_URL}?status=up&msg=Test%20complete&ping=")
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
if [ "$HTTP_CODE" -eq 200 ]; then
echo -e "${GREEN}✅ Statut remis à up${NC}"
else
echo -e "${RED}❌ Échec (HTTP $HTTP_CODE)${NC}"
fi
fi
echo ""
echo -e "${GREEN}==================================================${NC}"
echo -e "${GREEN}✅ Tous les tests de notification ont réussi !${NC}"
echo -e "${GREEN}==================================================${NC}"
echo ""
echo "Vérifiez que vous avez reçu 3 notifications sur votre appareil:"
echo -e "${YELLOW}Vérifications:${NC}"
echo ""
echo -e "${BLUE}Ntfy:${NC}"
echo " 1. Notification de test simple"
echo " 2. Notification de succès de backup"
echo " 3. Notification d'erreur de backup"
echo ""
if [ -n "$UPTIME_KUMA_PUSH_URL" ]; then
echo -e "${BLUE}Uptime Kuma:${NC}"
echo " 4. Monitor devrait montrer un changement up → down → up"
echo " 5. Vérifiez l'historique dans le dashboard Uptime Kuma"
echo ""
fi