PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
1. Seed command
- 1.1 Create
backend/cmd/seed_dev/main.goas a dev-only main package, following design decisions 1 to 4:- The seed takes the account, the names and both database endpoints as parameters, and
mainfills them from the repository.env, falling back to the defaults indocker-compose.yml. It imports no backend package, per design decision 1, so it starts without thelibeditshim. - It checks
GET /api/v1/system/healthfirst. It exits non-zero with "start the app withjust run" when the backend does not answer, and with the reason from the response body when the endpoint returns an error status. - It signs in, or signs up when sign-in fails, and stops naming the account when both fail.
- It finds or creates the workspace
Dev, the storageLocaland the databasesLogical PG16andWAL PG18. When the backend refuses a create call, the seed exits non-zero with the item's name and the backend's reason. - For each database it creates, it saves the backup config with backups on, the storage and the retention (3 logical backups, 2 WAL chains), then triggers the first backup the way
CreateDatabaseComponent.tsxdoes. - The package comment lists the account, the names, the sources, the two slot recovery steps and the disk usage case from design.md "Risks".
- Verify: in
backend/,go build ./cmd/seed_devandjust lintpass, andgo list -deps ./cmd | grep seed_devprints nothing. At the root,grep -n 'go build' Dockerfileshows that the server binary is built only from./cmd.
- The seed takes the account, the names and both database endpoints as parameters, and
- 1.2 Add
backend/cmd/seed_dev/main_test.go. It drives the seed againsthttptest.NewServerover a router built per design decision 1. The user controller's public routes and the healthcheck controller go on/api/v1without auth, asbackend/cmd/main.goregisters them. The workspace, storage and database controllers, both backup config controllers, and the logical and physical backup controllers go on a group behindAuthMiddleware. It uses the test database, a unique email per test, the logical fixture onTEST_LOGICAL_POSTGRES_16_PORTand the physical fixture onTEST_PHYSICAL_POSTGRES_18_PORT, and cleans up everything it created asbackend/AGENTS.md"Clean up test data" requires. The tests cover:- a fresh account gets the workspace, the storage and both databases with backups enabled, a first backup started, a logical retention of 3 backups and a physical retention of 2 chains;
- a second run creates nothing and leaves a database the test edited unchanged;
- a deleted database is recreated while the rest stays unchanged;
- an account with another password makes the seed fail with the account in the message, creates nothing and leaves that account's password and role unchanged;
- a separate account created before the seed runs keeps its password, role and settings afterwards;
- with two-factor sign-in required by the instance settings, the seed exits non-zero with the account and the two-factor reason and creates nothing;
- a failed sign-in or sign-up exits non-zero, which the test asserts for every failure case;
- a dev account that is a member, with member workspace creation switched off, makes the seed fail with the workspace name and the backend's reason, and changes no existing item;
- an unreachable base URL makes the seed fail with the
just runhint. - a stub
httptest.NewServerwhose/api/v1/system/healthanswers 503 with astatusreason makes the seed exit non-zero with that reason in the message, and no other request reaches the stub. A full disk is a failure the testing skill allows to fake, because it is unsafe to reproduce. - Verify:
just test-package ./cmd/seed_dev/...inbackend/.
2. Backend restart on change and seeding in just run
- 2.1 Add
"aqua:air-verse/air" = "1.67.4"tomise.toml. Verify:mise installsucceeds andmise exec -- air -vprints 1.67.4. - 2.2 Add
backend/.air.tomlper design decision 6, and addtmp/tobackend/.gitignore. Verify: inbackend/,go build -o ./tmp/databasus ./cmd(the configured build command) succeeds, andgit status --short --ignored tmpshowstmp/as ignored. Thengrep -nE '^\s*(include_ext|exclude_regex|stop_on_error|send_interrupt|kill_delay)\b' .air.tomlshowsinclude_ext = ["go"], anexclude_regexwith_test\.go,stop_on_error = false,send_interrupt = trueand a non-zerokill_delay. - 2.3 In
process-compose.yaml:- run the backend with
airinbackend/; - give the backend a readiness probe that checks that port 4005 accepts connections, per design decision 5;
- add a
seedprocess that runsgo run ./cmd/seed_devinbackend/after the backend is healthy, without restarts. - In
scripts/dev.sh, beforefree_backend_port, stop everyairprocess whose working directory is this worktree'sbackend/, and update the comment abovefree_backend_portper design decision 6. - Verify:
process-compose --config process-compose.yaml up --dry-runexits 0;grep -n -A8 '^ seed:' process-compose.yamlshowsdepends_onwithbackendandcondition: process_healthyandrestart: "no";grep -nE 'exit_on_end|exit_on_skipped|exit_on_failure' process-compose.yamlprints nothing, so a failed seed does not endjust run;bash -n scripts/dev.shpasses; andgrep -n 'air' scripts/dev.shshows the step comparing each process's working directory with$root/backend.
- run the backend with
3. Browser server for both agent clients
- 3.1 Add
"npm:chrome-devtools-mcp" = "1.11.0"tomise.toml. Verify:mise installsucceeds andmise exec -- chrome-devtools-mcp --versionprints 1.11.0. - 3.2 Add
BROWSER_HEADLESS=trueunder a# agent browsercomment to.env.exampleand to the local.env, which the user approved. Verify:grep -x 'BROWSER_HEADLESS=true' .env .env.examplematches in both files. - 3.3 Add the executable
scripts/browser-mcp.shper design decision 7: change into the repository root; read the environment first, then.envwithout sourcing it, then the defaulttrue; error on any other value;exec mise exec -- chrome-devtools-mcp --isolated --viewport 1440x900, adding--headlesswhen the value istrue. Verify withbash -n scripts/browser-mcp.sh, then with a copy of the launcher at$tmp/scripts/browser-mcp.sh, a temporary$tmp/.envand a stubmisefirst onPATHthat prints its arguments:- with no
BROWSER_HEADLESSin.envor the environment, the printed arguments contain--headlessand--isolated; - with
BROWSER_HEADLESS=falsein.env, they do not contain--headless; - with
BROWSER_HEADLESS=truein.envandBROWSER_HEADLESS=falsein the environment, they do not contain--headless; - with
BROWSER_HEADLESS=maybein.env, the launcher exits non-zero, the stub is not called, and stderr namesBROWSER_HEADLESS.
- with no
- 3.4 Register the server as
chrome-devtoolsin.mcp.jsonand in.codex/config.toml, both calling the launcher throughbash -candgit rev-parse --show-toplevel. Verify:python3 -m json.tool .mcp.jsonsucceeds, andcodex mcp list, run from the repository root, listschrome-devtoolswith the launcher command.
4. Agent instructions
- 4.1 Add
.agents/skills/run-app/SKILL.mdwith the rules from design decision 8 and spec requirement "The agent can see and drive the local app". It includes the rule to rerungo run ./cmd/seed_devinbackend/when the app of the agent's own worktree lacks the dev account or a seeded database. It links to the seed command's package comment for the account, names and ports instead of listing them. Add the symlink.claude/skills/run-app/SKILL.md->../../../.agents/skills/run-app/SKILL.md. Verify:readlink .claude/skills/run-app/SKILL.mdprints that target,grep -c '[email protected]' .agents/skills/run-app/SKILL.mdprints 0, andgrep -n 'cmd/seed_dev' .agents/skills/run-app/SKILL.mdmatches the rerun rule. - 4.2 In the root
AGENTS.md, update thejust runrow to mention the seed and the backend restart on change, and add a short "Checking the app in a browser" section that points to therun-appskill. Search the repository's Markdown for other descriptions ofjust runand bring them in line. Verify:grep -rn "just run\|just seed" --include=*.md . | grep -v openspec/finds nojust seedand everyjust runmention consistent with the new behavior. - 4.3 Run the root linters for the touched modules. Verify:
just lintexits 0.
Change verification
just test-package ./cmd/seed_dev/...