Database Backup Strategy Plan
This plan details how we will implement automated backups for the PostgreSQL database running on your ASUS server.
User Review Required
IMPORTANT
The backups will be saved on the host machine. You will need to ensure that the directory where the backups are stored is periodically synced or backed up externally (e.g., using Immich, a cloud provider, or an external hard drive) if you want off-site disaster recovery.
Open Questions
- Backup Retention: The default setup will keep daily backups for the last 7 days, weekly backups for the last 4 weeks, and monthly backups for 6 months. Does this retention policy sound good to you?
- Backup Schedule: The backups will run automatically every day at midnight (
@daily). Is this acceptable, or do you prefer a different time?
Proposed Changes
Add Automated Backup Service
We will add a dedicated background service to docker-compose.yaml using the popular prodrigestivill/postgres-backup-local image. This service runs completely transparently, meaning you won’t need to configure cron jobs manually on your ASUS server.
[MODIFY] docker-compose.yaml
- Add
pgbackupsservice linked to thedbservice. - Configure environment variables to connect to PostgreSQL (reusing the existing credentials from
.env). - Map a local volume
./backups:/backupsso the.sql.gzdump files are directly accessible from the ASUS server filesystem.
[MODIFY] .gitignore
- Add
/backupsto.gitignoreso that database dumps are never accidentally committed to GitHub.
Verification Plan
Manual Verification
- We will manually trigger a backup to ensure the image works correctly, authenticates with Postgres, and drops the
.sql.gzfile into the local./backupsfolder.