aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xalpine-backup12
-rw-r--r--rbu.conf6
2 files changed, 14 insertions, 4 deletions
diff --git a/alpine-backup b/alpine-backup
index 8e6ffbf..7acc3a9 100755
--- a/alpine-backup
+++ b/alpine-backup
@@ -8,6 +8,13 @@ die() {
exit 1
}
+mqtt_notify() {
+ local status="$1" size="$2" duration="$3"
+ local payload=$(printf '{ "status": "%s", "size": %u, "duration": %u }' "$status" "$size" "$duration")
+ local json=$(printf '{ "host": "%s", "key": "backup", "payload": %s }' "$FQDN" "$payload")
+ mosquitto_pub -h "$RBU_MQTT_HOST" $RBU_MQTT_TLS -t "$RBU_MQTT_TOPIC" -m "$json" $RBU_MQTT_AUTH
+}
+
for cmd in $CMD_DEPS; do
command -v $cmd >/dev/null 2>&1 || \
die "Error: command \"$cmd\" not found."
@@ -54,8 +61,5 @@ fi
ssh "$RBU_SERVER" mkdir -p $FQDN/logs
scp -q $LOGFILE "$RBU_SERVER:$FQDN/logs"
-PAYLOAD=$(printf '{ "status": "%s", "size": %u, "duration": %u }' "$STATUS" "$SIZE" "$DURATION")
-JSON=$(printf '{ "host": "%s", "key": "backup", "payload": %s }' "$FQDN" "$PAYLOAD")
-
-mosquitto_pub -h msg.alpinelinux.org -t "monitoring/updates" -m "$JSON"
+[ -n "$RBU_MQTT_HOST" ] && mqtt_notify "$STATUS" "$SIZE" "$DURATION"
diff --git a/rbu.conf b/rbu.conf
index 797adb2..1c40f13 100644
--- a/rbu.conf
+++ b/rbu.conf
@@ -16,6 +16,12 @@ export RBU_CACHE=/var/cache/backup
export RBU_LOCATION="$LBU_BACKUPDIR"
# ssh backup server to send backups to
export RBU_SERVER="user@backupserver.tld"
+# MQTT notification settings
+# Comment RBU_MQTT_HOST to disable notifications
+# export RBU_MQTT_HOST=
+# export RBU_MQTT_TOPIC=
+# export RBU_MQTT_TLS="-p 8883 --cafile /etc/ssl/cert.pem"
+# export RBU_MQTT_AUTH="-u username -P password"
# Custom profile settings