2.2 KiB
2.2 KiB
Runbook: Vaultwarden SQLite → Postgres (us2)
Target: us2.wsvc.info
Upstream: Using the PostgreSQL Backend · docs/vaultwarden-upstream.md
Done on 2026-08-01 for this host. Keep this as the replay checklist.
Summary of what we did
- Backup
vw-data+.env→backups/pre-pg-migrate-<timestamp>/ - Baseline counts from SQLite (then: users=1, ciphers=1327)
- Drop/recreate empty Postgres DB; pin image
vaultwarden/server:1.37.1 - Set compose
DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME} - Start VW once → diesel schema → stop
pgloaderdata only (exclude__diesel_schema_migrations) with CAST bigint→integer- Remaining intentional bigints:
attachments.file_size,twofactor.last_used,twofactor_duo_ctx.exp - Align
config.jsonSMTP 587/starttls,ip_header=X-Forwarded-For,DOMAINwithout trailing slash - Rotate
DB_PASS/PGWEB_PASS;pgwebbehind composeprofiles: [debug] - Move live sqlite file to
backups/sqlite-cold/(cold only) - After VW recreate, restart Traefik so Docker provider picks up the router
Critical pitfalls
config.jsonoverrides.env(admin wins). Fix SMTP there or via/admin.- SMTP password drift: if
.envAUTH works but VW mail fails with535, syncvw-data/config.json(+.smtp-credentials) to the mailbox password — do not assume env alone is enough. - From this network, mx2:465 times out; use 587 + starttls.
- After recreating
vaultwarden, Traefik may 404 untildocker restart traefik. - pgloader needs a writable directory for the sqlite file (CANTOPEN if mount is awkward).
- After pgloader, wrong integer types → silent “wrong password”; see Discussion #7134.
- Do not commit
.envor load files with passwords into git.
Rollback
docker compose stop vaultwarden- Restore
vw-datafrombackups/pre-pg-migrate-*(including sqlite) - Remove
DATABASE_URLfrom composeenvironment docker compose up -d vaultwarden&&docker restart traefik