blumeops/docs/how-to/operations/connect-to-postgres.md
Erich Blume 27d8f3cf1f Review gandi-operations doc and reorganize how-to guides (#200)
## Summary
- **Doc review:** Reviewed `gandi-operations.md` — added `last-reviewed` frontmatter, verified all wiki-links, confirmed Pulumi state has no drift
- **Gandi reference fix:** Added missing `cv.eblu.me` CNAME row to `gandi.md` DNS records table (was present in Pulumi but undocumented)
- **Pulumi comment fix:** Updated stale `README.md` reference in `__main__.py` to point to `docs/how-to/gandi-operations.md`
- **How-to reorg:** Moved 14 how-to guides into 3 subdirectories (`deployment/`, `configuration/`, `operations/`), collapsed the Documentation and Database index sections into Configuration and Operations respectively

## Verification
- `docs-check-links` — all 180 wiki-links valid
- `docs-check-filenames` — all 90 filenames unique
- `dns-preview` — 5 resources unchanged, no drift
- All pre-commit hooks pass

## Test plan
- [ ] Verify docs site builds correctly with new paths
- [ ] Spot-check a few wiki-links from other pages to moved how-to guides

Reviewed-on: https://forge.ops.eblu.me/eblume/blumeops/pulls/200
2026-02-17 07:29:33 -08:00

50 lines
1 KiB
Markdown

---
title: Connect to Postgres
modified: 2026-02-15
last-reviewed: 2026-02-15
tags:
- how-to
- database
---
# Connect to Postgres
How to connect to the [[postgresql]] cluster as a superuser using `psql`.
## Prerequisites
- `psql` installed (`brew install libpq` on macOS)
- [1Password CLI](https://developer.1password.com/docs/cli/) (`op`) installed and signed in
- Machine on the tailnet (e.g. [[gilbert]])
## Connect
```bash
PGPASSWORD=$(op read "op://blumeops/postgres/password") psql -h pg.ops.eblu.me -U eblume -d postgres
```
This connects as the `eblume` superuser. To connect to a specific database, replace `postgres` with the database name (e.g. `miniflux`, `teslamate`).
## Useful Queries
```sql
-- List databases
\l
-- List roles
\du
-- Check cluster status (CNPG)
SELECT pg_is_in_recovery();
-- Show active connections
SELECT datname, usename, client_addr, state
FROM pg_stat_activity
WHERE state IS NOT NULL;
```
## Related
- [[postgresql]] - Service reference
- [[borgmatic]] - Database backup
- [[troubleshooting]] - Cluster health checks