Skip to content
Merged
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
4 changes: 2 additions & 2 deletions scripts/backup-miner.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# gittensory-miner local-state backup (#4872): every store is an independent SQLite file directly under
# loopover-miner local-state backup (#4872): every store is an independent SQLite file directly under
# LOOPOVER_MINER_CONFIG_DIR (packages/loopover-miner/docs/operations-runbook.md's "Local state at a
# glance") -- there is no Postgres/Qdrant involved, so this is deliberately a simpler sibling to
# scripts/backup.sh, not a reuse of it (that script's manifest/multi-target logic has nothing to compose with
Expand All @@ -17,7 +17,7 @@
# LOOPOVER_MINER_CONFIG_DIR=/data/miner LOOPOVER_MINER_BACKUP_RETAIN=14 sh scripts/backup-miner.sh
set -eu

STATE_DIR="${LOOPOVER_MINER_CONFIG_DIR:-$HOME/.config/gittensory-miner}"
STATE_DIR="${LOOPOVER_MINER_CONFIG_DIR:-$HOME/.config/loopover-miner}"
OUT_DIR="${LOOPOVER_MINER_BACKUP_DIR:-$STATE_DIR/backups}"
RETAIN="${LOOPOVER_MINER_BACKUP_RETAIN:-7}"

Expand Down
8 changes: 4 additions & 4 deletions scripts/restore-miner.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# gittensory-miner local-state restore (#4872): the read side of scripts/backup-miner.sh. STOP the miner (and
# loopover-miner local-state restore (#4872): the read side of scripts/backup-miner.sh. STOP the miner (and
# any loop/systemd/docker service) before running this -- it overwrites the live state directory and does not
# detect a running process itself, the same "stop first" precondition operations-runbook.md's "ledger
# corrupted" scenario already documents for manual recovery.
Expand All @@ -15,14 +15,14 @@
# sh scripts/restore-miner.sh --yes /path/to/backups/<ts> # restores a specific backup
set -eu

STATE_DIR="${LOOPOVER_MINER_CONFIG_DIR:-$HOME/.config/gittensory-miner}"
STATE_DIR="${LOOPOVER_MINER_CONFIG_DIR:-$HOME/.config/loopover-miner}"
BACKUP_DIR="${LOOPOVER_MINER_BACKUP_DIR:-$STATE_DIR/backups}"

usage() {
cat <<USAGE >&2
Usage: $0 --yes [BACKUP_DIR]

Restores gittensory-miner local state from a backup produced by backup-miner.sh.
Restores loopover-miner local state from a backup produced by backup-miner.sh.

BACKUP_DIR A specific timestamped backup directory. Defaults to the newest one
under \$LOOPOVER_MINER_BACKUP_DIR ($BACKUP_DIR).
Expand Down Expand Up @@ -98,4 +98,4 @@ for db in "$SOURCE"/*.sqlite3; do
echo "[restore-miner] restored $name"
done

echo "[restore-miner] complete. Run 'gittensory-miner doctor --json' to verify."
echo "[restore-miner] complete. Run 'loopover-miner doctor --json' to verify."
28 changes: 28 additions & 0 deletions test/unit/miner-dr-scripts-config-default.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";

// Regression guard for #5933: the AMS miner's DR script pair (backup-miner.sh / restore-miner.sh) must default
// their working directory to the miner's real, current config dir (`~/.config/loopover-miner`, per
// packages/loopover-miner/lib/local-store.js's resolveLocalStoreDbPath) and NOT the pre-rename
// `~/.config/gittensory-miner`, so an operator who never sets LOOPOVER_MINER_CONFIG_DIR backs up/restores real
// state instead of a directory that no longer exists after the rebrand's hard cutover. These are `scripts/**`
// shell files, outside Codecov's coverage.include, so this content check is their only automated guard for the
// default (the sibling miner-backup-restore-scripts.test.ts always sets LOOPOVER_MINER_CONFIG_DIR explicitly, so
// it never exercises the default). Pattern mirrors test/unit/miner-docker-compose.test.ts: readFileSync + assert.
const SCRIPTS_DIR = join(process.cwd(), "scripts");
const CURRENT_DEFAULT = "$HOME/.config/loopover-miner";

describe("miner DR scripts default config dir (#5933)", () => {
for (const script of ["backup-miner.sh", "restore-miner.sh"]) {
const source = readFileSync(join(SCRIPTS_DIR, script), "utf8");

it(`${script} defaults STATE_DIR to the current ~/.config/loopover-miner`, () => {
expect(source).toContain(`STATE_DIR="\${LOOPOVER_MINER_CONFIG_DIR:-${CURRENT_DEFAULT}}"`);
});

it(`${script} carries no pre-rename gittensory-miner residue`, () => {
expect(source).not.toContain("gittensory-miner");
});
}
});