Files
tessera/tests/mbu/README.md
Adnan Zahir 6320b6f244 feat: add managed database capture and operator restore
PostgreSQL and MySQL backups run through paired outposts, with operator sign-in, off-site copies, and legacy import. Retention stays on each orbit, so the unused retention console is removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 23:26:49 +07:00

38 lines
4.1 KiB
Markdown

# MBU backup fixtures
Use a clean development host with Restic, PostgreSQL client/server tools, MySQL client tools, OpenSSL, OpenSSH, Docker, AWS CLI, Node.js and Python 3.9+. The SSH fixture uses a temporary loopback `sshd` and generated keys. Some Linux hosts require the distro's SSH privilege separation directory to exist before a non-root fixture can start.
```sh
rtk proxy npm --prefix web run build
rtk cargo build --workspace
rtk cargo test --workspace
rtk cargo test -p tessera-store -- --ignored
rtk proxy python3 tests/mbu/restic-orbits.py
rtk proxy python3 tests/mbu/capture-postgres.py
rtk proxy python3 tests/mbu/capture-mysql.py
rtk proxy python3 tests/mbu/restore-postgres.py
rtk proxy python3 tests/mbu/offsite.py
rtk proxy python3 tests/mbu/browser.py
rtk proxy python3 tests/mbu/legacy-import.py
rtk proxy python3 tests/mbu/matrix.py
```
- Restic orbits requires `rest-server` and `htpasswd` on PATH. It checks the four source/access combinations with a TLS Rest Server, re-runs after small changes, and verifies filesystem and PostgreSQL restores. Add `--mysql` to include MySQL capture and restore through both access modes.
- PostgreSQL covers direct TLS, verified PostgreSQL TLS through a pinned bastion, a mismatched hostname, a wrong host key, partial upload, a competing outpost, retry after a dropped reply, and a real restore to a second database.
- MySQL starts `mysql:9.2` by default. Use the matching `mysqldump` on PATH. Set `TESSERA_FIXTURE_MYSQL_IMAGE` to test a different server with a compatible client. The fixture covers direct and SSH capture, host-key failure, an engine error, and restore of data with a view, routine, and event.
- S3 starts `motoserver/moto:5.1.12` on loopback. It checks failed copy, retry, and export with the primary Restic repository offline.
- The browser test uses Playwright from Node's resolution path or `TESSERA_PLAYWRIGHT_MODULE` and its bundled Chromium or `TESSERA_FIXTURE_CHROME`. The fixture submits backup and restore jobs as an operator, exercises a capture-only profile, and verifies recovery status, the safety ID, and filesystem export. A fixture outpost handles the scoped job protocol.
- PostgreSQL restore verifies target identity, scoped payload access, checksum rejection, safety pinning, schema and recreate modes, a PostgreSQL 17 dump restored to PostgreSQL 14, restricted psql commands, and restart after reset. The fixture uses the PostgreSQL 14 host tools and the postgres:17 container for the newer source.
- The legacy import fixture reads compressed SQL archives from S3, restores synthetic samples, and verifies history access and idempotency after local GC.
- The matrix pairs three outposts, runs ten application profiles against isolated databases, exercises a scheduler tick for 02.00 WIB, and checks manual capture, scheduled capture, registered restore targets, and S3 copies. Its JSON output records durations, freshness, size and restore results.
## Placement inventory and fixture mapping
Read-only Teleport inventory on 10 November 2026 showed `odoo-clone`, `production-FTA`, `fta-prod`, `broiler-production`, `broiler-staging` and `mbu-backup-jumphost`. Database inventory reported the Broiler resource `mbu-production` with the MySQL protocol. MAS and FTA had no matching database resource in the approved inventory. The returned metadata had no server-version labels. The approved Machine ID could list resources, but the attempted `devops` OS login returned `unknown user devops` on `odoo-clone`, `production-FTA`, `broiler-production`, and `mbu-backup-jumphost`. Verification of deployed client/server versions, routes and privileges requires an authorized existing OS login on the applicable nodes.
| Case | Fixture | Placement to validate |
| --- | --- | --- |
| MAS and FTA | PostgreSQL TLS behind a loopback SSH bastion, wrong host key case | Run near the database if there is direct access. Otherwise use a pinned SSH forward to the database and validate the PostgreSQL server hostname. |
| Boiler | MySQL behind a pinned SSH login, wrong host key and engine-error cases | Use the matched MySQL client on the SSH host and a private client options file. |