Skip to content

dbbackup: discover every database on every server over ssh - #64

Merged
ralyodio merged 2 commits into
mainfrom
feat/dbbackup-discover
Oct 17, 2026
Merged

ralyodio merged 2 commits into
mainfrom
feat/dbbackup-discover

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

What

diskpush dbbackup discover [SERVER...] [--save] finds every database on every server DiskPush already knows (saved connections + ~/.ssh/config hosts, i.e. diskpush fleet servers), over the ssh keys/agent already in use, and --save keeps them for backup. A saved database can now live on a server: its dump runs there and only the bytes come back over ssh.

Found How Backed up with
Postgres / Supabase in Docker docker ps image match, then psql inside the container (POSTGRES_USER / postgres / supabase_admin, socket or 127.0.0.1) docker exec <c> pg_dump …
MySQL / MariaDB in Docker mysql -uroot inside with the container's own root password docker exec <c> mysqldump …
Native Postgres each online cluster as the postgres OS user sudo -n -u postgres pg_dump -p <port>
Native MySQL root over the socket mysqldump as root
SQLite header-checked files under /srv /opt /var/www /root /home (setting sqliteRoots), skipping deps/caches/checkouts/worktrees/hidden/backups/tmp/opencode sqlite3 .backup + quick_check on the server, file streamed back

No database port opened, no database password copied, no local pg_dump needed. The existing gzip + completion-line rule still applies, so a dump cut short is discarded.

Pieces

  • plugin-api: optional, additive BaseContext.servers (ServerRef list, knownHostsFiles, sshConfigFile). No API version bump; wired in the CLI (serverDirectory) and desktop hosts.
  • ssh-core: toServerRef().
  • dbbackup: discover.ts (probe, parser, naming, reconcile, save), remote.ts (ssh argv with BatchMode=yes, remote dump commands, run-as whitelist), DatabaseConfig.server/via/container/database/dbUser/dbHost/port/runAs, desktop task Find databases on every server, ssh in doctor.
  • Git forges and duplicate user@host:port aliases are skipped; aliases reaching the same machine (/etc/machine-id) are listed once under the one with most access. Unknown host keys fail unless --accept-new.

Tests

  • 922/922 (umask 022), pnpm -r typecheck clean, ThreatCrush plugin gate passes (only LOW masked fixture URLs in tests).
  • New discover.test.ts: probe parser, owners from env files, naming, reconcile and idempotent save, server picking and same-machine merge, ssh argv, remote dump commands, run-as refusal; the real probe script run against a fake docker and a temp SQLite tree; and discover, save, back up and verify through a fake ssh, including a truncated dump and a SQLite round trip with restore.

Live

  • Read-only discover across the real fleet: 142 databases on 7 of 8 servers (dev2: 65 Supabase incl. the shared supabase-db cluster's per-app DBs, 3 Postgres, 24 SQLite; vienna 46 SQLite; bbs-root 4). 77 git aliases skipped; seed3/seed2 correctly merged into dev2/vienna; bbs1 (:22 is the BBS) reported as no shell.
  • End to end on dev2 in a throwaway DISKPUSH_HOME: discover --save, then run backed up a Supabase stack, a shared-cluster app DB, a Postgres container and a SQLite volume over ssh; all verify, and the SQLite copy passes integrity_check.

🤖 Generated with Claude Code

ralyodio and others added 2 commits October 17, 2026 09:34
`diskpush dbbackup discover [SERVER...] [--save]` looks on each saved
connection and ~/.ssh/config host with one read-only probe per server and
finds Postgres/Supabase/MySQL in Docker or native, SQLite files, and the
app env files that use them. --save keeps them; running it again adds only
what is new and names saved ones a reachable server no longer has.

Databases can now live on a server: the dump runs there (docker exec
pg_dump / mysqldump, sudo -u postgres pg_dump, sqlite3 .backup +
quick_check) and only the bytes come back over `ssh -o BatchMode=yes`,
through the same gzip + completion-line check. No database port opened,
no password copied, no local pg_dump needed.

- plugin-api: optional, additive BaseContext.servers (ServerRef list,
  known_hosts files, ssh_config path); wired in the CLI and desktop hosts
- ssh-core: toServerRef()
- git forges and duplicate logins are skipped; aliases that reach the
  same machine (/etc/machine-id) are listed once
- desktop task "Find databases on every server"; setting sqliteRoots
- docs/plugins.md, README

Live-tested read-only against the fleet (370 -> ~180 real databases after
noise filters on 7 of 8 servers) and end to end on dev2: a Supabase stack,
a shared-cluster app database, a plain Postgres container and a SQLite
volume backed up over ssh and verified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Vienna tenant homes held .retired/ app copies and backups/ full of dated
copies; the live fleet count drops from 175 to 142 real databases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ralyodio
ralyodio merged commit 828e13c into main Oct 17, 2026
6 checks passed
@ralyodio ralyodio mentioned this pull request Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant