Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions nixos/home/pm-dashboard-backup-copy.test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Tests for pm-dashboard-backup.sh's dataset staging copies (#1023):
# the copies that stage the aggregator files, the snapshots tree, the
# meta-quota-export files, and the db-dumps dir were unchecked, and the
# meta-quota-export files, and the staged dumps dir were unchecked, and the
# manifest is generated by walking the staged tree — so a failed copy
# (a present but unreadable dataset file) was invisible to the verify
# step: the run reported full success with an incomplete archive,
Expand All @@ -14,7 +14,7 @@
# file, nothing uploaded, marker unchanged
# * unreadable snapshots file — same, naming the snapshots tree
# * unreadable meta-export file — same, naming the file
# * unreadable db-dumps file — same, naming the dumps dir
# * unreadable dumps file — same, naming the pm-stack source dir
# * missing required file (control) — WARN at staging as before
# (absent is not unreadable: no dataset-copy failure), but since
# #1025 the run then FAILS at verify naming the member, uploads
Expand Down Expand Up @@ -95,7 +95,7 @@ setup_and_run() {
local agg="$HOME_DIR/.local/state/pm-aggregator"
local meta="$HOME_DIR/atlas/meta-quota-export"
mkdir -p "$HOME_DIR/backups/dashboard" "$agg/snapshots" "$meta" \
"$HOME_DIR/backups/db-dumps/$DATE_ARG"
"$HOME_DIR/backups/pm-stack/$DATE_ARG"
local f
for f in actions.json comments.json fleet-feed.json quota-current.json \
registry.json quota-gatherer-state.json quota-gatherer-heartbeat.json; do
Expand All @@ -104,7 +104,7 @@ setup_and_run() {
printf '{}\n' >"$agg/snapshots/snap1.json"
printf '{}\n' >"$meta/latest.json"
printf '{}\n' >"$meta/history.jsonl"
printf 'dump\n' >"$HOME_DIR/backups/db-dumps/$DATE_ARG/dump.sql"
printf 'dump\n' >"$HOME_DIR/backups/pm-stack/$DATE_ARG/dump.sql"
echo "$PRESET" >"$HOME_DIR/backups/dashboard/.last-run-epoch"
if [[ -n "$break_rel" ]]; then
if [[ "$break_rel" == MISSING:* ]]; then
Expand Down Expand Up @@ -156,8 +156,8 @@ expect_copy_failure unreadable-snapshots "snapshots"
setup_and_run unreadable-meta "atlas/meta-quota-export/latest.json"
expect_copy_failure unreadable-meta "latest.json"

setup_and_run unreadable-dumps "backups/db-dumps/$DATE_ARG/dump.sql"
expect_copy_failure unreadable-dumps "db-dumps"
setup_and_run unreadable-dumps "backups/pm-stack/$DATE_ARG/dump.sql"
expect_copy_failure unreadable-dumps "pm-stack"

# Control: a missing dataset file still only WARNs at staging (absent
# is not unreadable — no dataset-copy failure), but comments.json is a
Expand Down
8 changes: 4 additions & 4 deletions nixos/home/pm-dashboard-backup-manifest.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
# * dump-ran-no-dir — the dump step ran (stub script, exit 0) but
# produced no dumps dir: db-dumps is conditionally REQUIRED, so
# the run fails naming db-dumps, cursor unchanged.
# * dump-ran-with-dir — the dump step produced its dir: db-dumps
# recorded required + present, run completes.
# * dump-ran-with-dir — the dump step produced its dir: the staged
# db-dumps member is recorded required + present, run completes.
set -uo pipefail

SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Expand Down Expand Up @@ -96,8 +96,8 @@ chmod +x "$BIN/bws" "$BIN/journalctl" "$BIN/rclone"
DUMPBIN="$TMP_ROOT/dump-bin"
mkdir -p "$DUMPBIN"
{ printf '#!%s\n' "$BASH"; cat <<'STUB'
mkdir -p "$HOME/backups/db-dumps/$1"
printf 'dump bytes\n' >"$HOME/backups/db-dumps/$1/dump.sql"
mkdir -p "$HOME/backups/pm-stack/$1"
printf 'dump bytes\n' >"$HOME/backups/pm-stack/$1/dump.sql"
exit 0
STUB
} >"$DUMPBIN/dump-with-dir.sh"
Expand Down
4 changes: 2 additions & 2 deletions nixos/home/pm-dashboard-backup-record.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ run_scenario() {
dump_script="$home/dump-ok.sh"
{
printf '#!%s\n' "$BASH"
printf '%s\n' 'mkdir -p "$HOME/backups/db-dumps/$1"'
printf '%s\n' 'printf "{}\n" > "$HOME/backups/db-dumps/$1/dump.sql"'
printf '%s\n' 'mkdir -p "$HOME/backups/pm-stack/$1"'
printf '%s\n' 'printf "{}\n" > "$HOME/backups/pm-stack/$1/dump.sql"'
} >"$dump_script"
chmod +x "$dump_script"
elif [[ $dump_mode == "fail" ]]; then
Expand Down
14 changes: 9 additions & 5 deletions nixos/home/pm-dashboard-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,16 @@ ledger_set credentials ok

# --- optional pm-stack DB dumps (code#1514) --------------------------------
# The #1514 dump job (Kaneo Postgres + Grist + Pad) publishes its script at
# ~/tools/pm-stack-db-backup.sh and writes dumps to ~/Backups/db-dumps/<date>/
# (here: ~/backups/db-dumps/<date>/). When present it runs first and its
# output rides this archive to all three destinations; until it lands, the
# archive carries the dashboard state set only and says so in the log.
# ~/tools/pm-stack-db-backup.sh (a bridge to pm-stack-backup.sh) and writes
# dumps to ~/backups/pm-stack/<date>/ (here: $DUMP_DIR). When present it runs
# first and its output rides this archive to all three destinations; until
# it lands, the archive carries the dashboard state set only and says so in
# the log. (nix#1365: DUMP_DIR previously pointed at ~/backups/db-dumps,
# which the dump script never writes — every run with DUMP_RAN=1 then failed
# verify as required-member-missing. The staged tree keeps its historic
# db-dumps name; only the source dir changed.)
DUMP_SCRIPT="${PM_DB_DUMP_SCRIPT:-$HOME/tools/pm-stack-db-backup.sh}"
DUMP_DIR="$HOME/backups/db-dumps/$DATE"
DUMP_DIR="$HOME/backups/pm-stack/$DATE"
DUMP_RAN=0
if [ -x "$DUMP_SCRIPT" ]; then
ledger_begin db-dump
Expand Down
Loading