diff --git a/cmd/jeannie-core/main.go b/cmd/jeannie-core/main.go index 0fae7e5..b097e72 100644 --- a/cmd/jeannie-core/main.go +++ b/cmd/jeannie-core/main.go @@ -504,6 +504,10 @@ func diagnoseReportRow(row reportRow) reportDiagnosis { } switch { + case strings.Contains(strings.ToLower(row.Check), "backup freshness"): + diagnosis.Cause = "Review the individual backup checks for stale or missing archives and unverified coverage. The reported result does not establish why the upload failed." + diagnosis.Mitigate = "Check OCI backup freshness and the scheduled upload service; verify native K3s datastore and volume coverage separately." + diagnosis.Redesign = "Run encrypted uploads under the configured operator account and monitor upload failures and restore verification." case containsAny(text, "connection refused", "connect: connection refused", "couldn't connect to server", "no route to host", "network is unreachable", "timed out", "i/o timeout"): diagnosis.Cause = "The target is not accepting traffic from this network path. The usual break is service down, wrong backend IP/port, route advertisement, firewall/NAT, or MetalLB address ownership." diagnosis.Mitigate = "Test the next hop directly from the host that failed, then restart or reapply the owning layer shown by the check. For public URL failures, compare Debian -> Traefik and OCI edge -> Traefik before changing app code." diff --git a/docs/app-ops.md b/docs/app-ops.md index db5d6f0..2c8119f 100644 --- a/docs/app-ops.md +++ b/docs/app-ops.md @@ -1,5 +1,14 @@ # Application Operations +## OCI backup scheduling + +Run `./jeannie backup oci schedule` as the Debian operator to install the daily +upload and freshness timers under that account. Run `./jeannie backup oci upload` +for a fresh encrypted archive, then `./jeannie backup oci freshness` and +`./jeannie backup oci restore-verify` to check upload age and archive recovery. +The profile archive contains inventory, Gitea backup, and OpenTofu state; it +does not establish coverage of the native K3s datastore or PVC data. + ## Profile-aware diagnostics and healing Persist the operational cluster on the Debian deployment host with diff --git a/docs/templates/app-ops.md.tmpl b/docs/templates/app-ops.md.tmpl index acebc40..62780e2 100644 --- a/docs/templates/app-ops.md.tmpl +++ b/docs/templates/app-ops.md.tmpl @@ -1,5 +1,14 @@ # Application Operations +## OCI backup scheduling + +Run `./jeannie backup oci schedule` as the Debian operator to install the daily +upload and freshness timers under that account. Run `./jeannie backup oci upload` +for a fresh encrypted archive, then `./jeannie backup oci freshness` and +`./jeannie backup oci restore-verify` to check upload age and archive recovery. +The profile archive contains inventory, Gitea backup, and OpenTofu state; it +does not establish coverage of the native K3s datastore or PVC data. + ## Profile-aware diagnostics and healing Persist the operational cluster on the Debian deployment host with diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 08b23d6..f93818b 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -1472,10 +1472,12 @@ status_cascade_check() { status_cascade_warn() { local description="$1" local output + local fix="./jeannie explain status" shift if truthy "${JEANNIE_REPORT_MODE:-false}"; then - report_ui_check warn "${STATUS_CURRENT_SECTION:-Status}" "${description}" "./jeannie explain status" "" "" "$@" + [[ "${description}" != "Backup freshness" ]] || fix="./jeannie backup oci freshness" + report_ui_check warn "${STATUS_CURRENT_SECTION:-Status}" "${description}" "${fix}" "" "" "$@" return 0 fi @@ -4777,7 +4779,6 @@ install_homelab_backup_timer() { # Optional offsite target examples: # HOMELAB_BACKUP_OFFSITE_URI=file:///mnt/git-backups/homelab-profile # HOMELAB_BACKUP_OFFSITE_URI=ssh://ubuntu@100.118.255.19/mnt/git-backups/homelab-profile -LAB_CLUSTER_PROFILE=pimox KUBECONFIG_PATH=${kubeconfig} ENV_EOT if [[ -n "${offsite_uri}" ]]; then @@ -4799,6 +4800,8 @@ Wants=network-online.target [Service] Type=oneshot +User=$(id -un) +Environment=JEANNIE_SERVICE_CONTEXT=true EnvironmentFile=-${env_file} WorkingDirectory=${REPO_ROOT} ExecStart=${REPO_ROOT}/jeannie backup diff --git a/scripts/oci-backup b/scripts/oci-backup index 4030e9a..36fb7b7 100755 --- a/scripts/oci-backup +++ b/scripts/oci-backup @@ -62,7 +62,7 @@ upload_archive() { object="${PREFIX%/}/$(basename "${archive}")" checksum_file="$(mktemp)" trap 'rm -f "${checksum_file}"' RETURN - sha256sum "${archive}" >"${checksum_file}" + printf '%s archive.tgz.age\n' "$(sha256sum "${archive}" | awk '{print $1}')" >"${checksum_file}" "${oci_bin}" os object put --config-file "${OCI_CONFIG}" --profile "${OCI_PROFILE}" \ --region "${OCI_REGION}" --namespace-name "${NAMESPACE}" --bucket-name "${BUCKET}" \ --name "${object}" --file "${archive}" --force >/dev/null diff --git a/scripts/oci-backup-schedule b/scripts/oci-backup-schedule index d66498a..c7bbf38 100755 --- a/scripts/oci-backup-schedule +++ b/scripts/oci-backup-schedule @@ -6,6 +6,11 @@ service=/etc/systemd/system/homelab-oci-backup.service timer=/etc/systemd/system/homelab-oci-backup.timer fresh_service=/etc/systemd/system/homelab-oci-backup-freshness.service fresh_timer=/etc/systemd/system/homelab-oci-backup-freshness.timer +service_user="$(id -un)" +if [[ "$(id -u)" == 0 ]]; then + echo 'Run this command as the Debian operator, not root, so the timers use the correct OCI credentials and state.' >&2 + exit 1 +fi sudo tee "${service}" >/dev/null </dev/null 2>&1 || ! command -v jq >/dev/null 2>&1; then printf 'skipped: curl and jq are required to ask the AI gateway for RCA.\n' printf 'fix: install curl jq, or rerun with --no-local-rca.\n' @@ -217,11 +217,11 @@ report_ui_local_rca() { prompt="$(cat <