mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-25 14:34:38 +02:00
feat(infra): add pgBackRest for PostgreSQL Point-in-Time Recovery
Replace simple pg_dumpall with pgBackRest PITR backup system. This enables recovery to any second, not just the last daily dump. Configuration: - docker/postgres/postgresql.conf: WAL archiving + performance tuning (shared_buffers=512MB, effective_cache_size=2GB for 16GB Mac Mini) - docker/postgres/pgbackrest.conf: stanza config + retention policy Docker (docker-compose.macmini.yml): - postgres: mount custom config, enable WAL archiving - postgres-backup: new pgBackRest container - Storage: /Volumes/ManaData/backups/pgbackrest - Retention: 4 full + 14 differential (~4 weeks) - Compression: Zstandard (zst) Backup Schedule: - 03:00 daily: Full backup - Every 6h: Differential (changes since last full) - Every hour: Incremental (changes since last backup) - Continuous: WAL archiving (every 60s) Documentation (docs/POSTGRES_BACKUP.md): - Complete restore procedures (full, PITR, single DB) - First-time setup instructions - Monitoring and alerting integration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
979564540a
commit
39526918a3
4 changed files with 251 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ services:
|
|||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-mana123}
|
||||
volumes:
|
||||
- /Volumes/ManaData/postgres:/var/lib/postgresql/data
|
||||
- ./docker/postgres/postgresql.conf:/etc/postgresql/conf.d/custom.conf:ro
|
||||
ports:
|
||||
- "5432:5432"
|
||||
healthcheck:
|
||||
|
|
@ -34,6 +35,31 @@ services:
|
|||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
command: >
|
||||
postgres
|
||||
-c 'config_file=/etc/postgresql/conf.d/custom.conf'
|
||||
|
||||
# PostgreSQL Backup with Point-in-Time Recovery
|
||||
# Full backup daily at 03:00, differential every 6h, incremental every hour
|
||||
# Retention: 4 full backups + 14 differential
|
||||
# Restore: see docs/POSTGRES_BACKUP.md
|
||||
postgres-backup:
|
||||
image: pgbackrest/pgbackrest:latest
|
||||
container_name: mana-infra-pgbackrest
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
PGBACKREST_STANZA: mana
|
||||
PGBACKREST_REPO1_PATH: /var/lib/pgbackrest
|
||||
PGBACKREST_REPO1_RETENTION_FULL: "4"
|
||||
PGBACKREST_PG1_HOST: postgres
|
||||
PGBACKREST_PG1_PORT: "5432"
|
||||
PGBACKREST_PG1_USER: postgres
|
||||
PGBACKREST_PG1_PATH: /var/lib/postgresql/data
|
||||
volumes:
|
||||
- /Volumes/ManaData/backups/pgbackrest:/var/lib/pgbackrest
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue