rearange borgmatic setup and configuration
This commit is contained in:
26
borgmatic/scripts/mqtt.sh
Executable file
26
borgmatic/scripts/mqtt.sh
Executable 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"
|
||||
10
borgmatic/scripts/run-old.sh
Normal file
10
borgmatic/scripts/run-old.sh
Normal 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
4
borgmatic/scripts/run.sh
Executable 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
|
||||
Reference in New Issue
Block a user