Commit Graph

3 Commits

Author SHA1 Message Date
xarmian 9be8e96cfd fix(cli): safe SQLite db backup/restore (config path + VACUUM INTO) (#837)
* fix(cli): safe SQLite db backup/restore (config path + VACUUM INTO)

pad db backup/restore hardcoded ~/.pad/pad.db, so `docker exec pad db
backup` (container sets PAD_DATA_DIR=/data) and Windows layouts broke,
and the SQLite path did a torn io.Copy of pad.db + separate -wal/-shm
copy that could lose or tear in-flight WAL writes.

- Resolve the SQLite path via the server's config loader (PAD_DB_PATH >
  PAD_DATA_DIR/pad.db > ~/.pad/pad.db) instead of os.Getenv("HOME").
  Covers backup, restore, and migrate-to-pg's --from default.
- Replace the file copy with an online-safe `VACUUM INTO` through the
  embedded modernc.org/sqlite driver: one self-contained file, no
  -wal/-shm juggling, safe while the server is live.
- Restore refuses when a live server is detected (a running WAL
  checkpoint could clobber the restored file); --force overrides.
- docs/backup.md: `pad db backup -o <file>` is the canonical SQLite
  path (+ the `docker exec <container> pad db backup -o /data/backup.db`
  form); dropped the "PostgreSQL-only" mislabel.

PostgreSQL pg_dump/psql paths are unchanged.

Fixes BUG-1996.

Claude-Session: https://claude.ai/code/session_01BoPkYhKqMiWPYmxQigeWsA

* fix(cli): fail restore on stale sidecar removal + drop unsafe backup doc

Address Codex review P2s:
- Restore: treat a failure to remove a stale -wal/-shm at the target as
  fatal (was silently ignored). With single-file VACUUM INTO backups a
  leftover sidecar would replay old WAL state over the restored DB.
- docs/backup.md: the SQLite strategy block still recommended a raw
  `cp pad.db` daily; point it at `pad db backup --cron` instead.

Claude-Session: https://claude.ai/code/session_01BoPkYhKqMiWPYmxQigeWsA
2026-07-07 15:21:20 -04:00
xarmian ac744fce2b fix(docs): replace 'pad serve' with 'pad server start' (TASK-675) (#199)
The 'pad serve' command does not exist in this binary — its canonical
name has been 'pad server start' for some time. Users following the
systemd example in docs/deployment.md would get a non-starting service
today. Six real references fixed:

  - cmd/pad/main.go:5714 — migrate-to-pg help text
  - cmd/pad/main.go:5795 — 'Next steps' instruction
  - docs/backup.md:81,94 — Postgres migration walkthrough
  - docs/deployment.md:116 — binary launch example
  - docs/deployment.md:164 — systemd ExecStart

Repo-wide grep is now clean of 'pad serve' outside gitignored
v1-archive/ and .pad/ (local workspace data). README.md was already
correct.

Parent: PLAN-644.
2026-04-22 14:50:24 -04:00
xarmian 1d26283752 feat: add PostgreSQL backup, restore, and migration CLI commands
- pad db backup: wraps pg_dump with --output and --cron flags
- pad db restore: wraps psql with confirmation prompt and --force
- pad db migrate-to-pg: one-time SQLite→PostgreSQL migration using
  application-level export/import for all workspace data
- docs/backup.md: comprehensive backup strategy guide covering SQLite,
  PostgreSQL, cloud snapshots, and disaster recovery
2026-04-06 02:01:51 +00:00