rearange borgmatic setup and configuration

This commit is contained in:
2025-10-01 19:49:05 +02:00
parent 33546d7e72
commit 16ffd6ab60
13 changed files with 170 additions and 331 deletions

26
borgmatic/scripts/mqtt.sh Executable file
View File

@@ -0,0 +1,26 @@
CONFIG_FILE="$1"
MQTT_BROKER="host"
MQTT_TOPIC="borgmatic/stats/$CONFIG_FILE"
MQTT_USER="borgmatic"
MQTT_PASSWORD="eH2dAiG7siCIFdB7qX0MHwEFzcr9aqUi"
# Run Borgmatic and extract archive stats as JSON
PAYLOAD=$(borgmatic \
--stats \
-v 0 \
-c "/config/$CONFIG_FILE.yaml" \
--log-json \
--no-color \
--json \
| tee /dev/tty \
| sed --quiet '/^\[/p' \
| jq '.[0].archive'
)
# Publish to MQTT
mosquitto_pub -h "$MQTT_BROKER" \
-t "$MQTT_TOPIC" \
-u "$MQTT_USER" \
-P "$MQTT_PASSWORD" \
-m "$PAYLOAD"