PostgreSQL
Overview
Section titled “Overview”PostgreSQL is a powerful, open-source relational database.
Key features:
- ACID compliance
- Advanced indexing
- Full-text search
- JSON support
Installation
Section titled “Installation”shc install postgres --stack dbCommon variables:
postgres_user- Superuser name (default: postgres)postgres_password- Superuser password (auto-generated)postgres_db- Initial database name
Configuration
Section titled “Configuration”PostgreSQL provides a socket for other apps:
shc install postgres --stack dbshc install keycloak --stack iam # Auto-connects to postgresThe socket exports:
POSTGRES_HOST- Database hostnamePOSTGRES_PORT- Port (default: 5432)POSTGRES_USER- UsernamePOSTGRES_PASSWORD- Password (from vault)POSTGRES_DB- Database name
Backup
Section titled “Backup”PostgreSQL uses pg_dump converter for consistent backups:
shc backup create --stack dbThe backup includes:
- All databases (via pg_dump)
- User roles and permissions
- Configuration files
Restore with pg_restore:
shc restore --stack db --backup abc123.bakAccess Database
Section titled “Access Database”# Interactive shellshc shell --stack db --service postgres
# Inside containerpsql -U postgres
# Run SQL commandshc exec --stack db --service postgres -- \ psql -U postgres -c "SELECT version();"Troubleshooting
Section titled “Troubleshooting”Common issues:
Problem: Connection refused
Solution: Check if the service is healthy: shc status db
Problem: Authentication failed
Solution: Verify password: shc vault get db/postgres_password
See Also
Section titled “See Also”shc@docs:~$