#!/usr/bin/env bash # Read /srv/backups/status/last-run.json. Returns "{}" if missing, so the # dashboard can render an "unknown" state instead of erroring. set -uo pipefail STATUS_FILE="${STATUS_FILE:-/srv/backups/status/last-run.json}" RESTORE_STATUS_FILE="${RESTORE_STATUS_FILE:-/srv/backups/status/last-restore-test.json}" # We emit a small wrapper object with both files so the UI can render the # server-backup status AND the most recent restore-test status from one call. last_run='{}' if [ -r "$STATUS_FILE" ]; then last_run=$(cat "$STATUS_FILE") fi last_restore='null' if [ -r "$RESTORE_STATUS_FILE" ]; then last_restore=$(cat "$RESTORE_STATUS_FILE") fi jq -n \ --argjson last_run "$last_run" \ --argjson last_restore "$last_restore" \ '{ last_run: $last_run, last_restore_test: $last_restore }'