EcoSpecies-Atlas/docs/postgres-backup.md

49 lines
1.4 KiB
Markdown

# PostgreSQL Backup Notes
This note applies to deployments that use the PostgreSQL volume defined by the Compose stack, including the Traefik deployment variant.
## What Needs Backup
At minimum, back up:
- the PostgreSQL data volume
- the deployment env file that contains the database credentials
For the Traefik deployment variant, that usually means:
- the Docker volume `postgres_data`
- `docs/docker-compose-traefik.env`
## Logical Backup
From the repository root, create a SQL dump with:
```bash
./scripts/backup-postgres.sh
```
To write to a specific file:
```bash
./scripts/backup-postgres.sh /path/to/ecospecies-backup.sql
```
## Restore From Logical Backup
Restore a SQL dump with:
```bash
./scripts/restore-postgres.sh /path/to/ecospecies-backup.sql
```
## Volume-Level Backup
If the host backup system can snapshot Docker volumes safely, include the PostgreSQL volume in that schedule. A volume snapshot is useful for full recovery, but a logical dump is still recommended for portability and validation.
## Operational Guidance
- Run backups on a schedule instead of relying on ad hoc dumps.
- Test restore procedures before relying on the backup policy.
- Keep backup artifacts outside the live Docker host when possible.
- The backup and restore scripts default to `docs/docker-compose-traefik.env` and `docs/docker-compose-traefik.yml`, but both can be overridden with `ECOSPECIES_ENV_FILE` and `ECOSPECIES_COMPOSE_FILE`.