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
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>
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user