diff --git a/.env.example b/.env.example index bd0d329..a18c3e3 100644 --- a/.env.example +++ b/.env.example @@ -29,6 +29,14 @@ 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 + # ============================================ # OPTIONS AVANCÉES # ============================================ diff --git a/config.yaml b/config.yaml index 9b1ef2c..fea77f5 100644 --- a/config.yaml +++ b/config.yaml @@ -80,13 +80,15 @@ commands: - after: action when: [create] run: - - echo "Exécution hook de succès" + - 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 hook d'erreur" + - 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 diff --git a/hooks/uptime-kuma-error.sh b/hooks/uptime-kuma-error.sh new file mode 100755 index 0000000..a44575c --- /dev/null +++ b/hooks/uptime-kuma-error.sh @@ -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 diff --git a/hooks/uptime-kuma-success.sh b/hooks/uptime-kuma-success.sh new file mode 100755 index 0000000..cdf0e99 --- /dev/null +++ b/hooks/uptime-kuma-success.sh @@ -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