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"

View File

@@ -0,0 +1,10 @@
borgmatic --stats -v 0 -c /config/home.yaml >> /log/home.log 2>&1
borgmatic --stats -v 0 -c /config/root.yaml >> /log/root.log 2>&1
borgmatic --stats -v 0 -c /config/opt.yaml >> /log/opt.log 2>&1
borgmatic --stats -v 0 -c /config/etc.yaml >> /log/etc.log 2>&1
export REMOTE=/remote/server/bram
mkdir -p ${REMOTE}
sshfs user@bram.veenboer.xyz:/media/helios/Bram ${REMOTE}
borgmatic --stats -v 0 -c /config/bram.yaml >> /log/bram.log 2>&1
umount ${REMOTE}

4
borgmatic/scripts/run.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
for name in home root opt etc bram; do
/scripts/mqtt.sh "$NAME" >> "/log/$NAME.log" 2>&1
done