Sign inSign up

ethoslink/postgres-backrest

By ethoslink

•Updated 3 months ago

A production-ready PostgreSQL image with PgBackRest preinstalled and sensible default configuration.

Image
1

2.4K

ethoslink/postgres-backrest repository overview

⁠Postgres + PgBackRest

Maintained by Ethos Link Docker Pulls

A production-ready PostgreSQL image with PgBackRest preinstalled and sensible default configuration.

This image is maintained by Ethos Link⁠. It is a small, reusable extract from operational work we do for Reviato⁠, a review intelligence product built by Ethos Link.

The goal is simple: make it easy to run Postgres with backups and predictable configuration without turning your repo into an ops research project.

⁠About

We believe in open source and sharing operational knowledge. If you like this project, see:

  • git-markdown⁠: A tool to convert git repos into LLM-friendly markdown.
  • Reviato⁠: Intelligent review management for automated businesses.

⁠What you get

  • PostgreSQL + PgBackRest in one image (based on the upstream postgres image)
  • WAL archiving-ready defaults (pair this with a PgBackRest repo config)
  • Bring-your-own postgresql.conf (pgtune-friendly) via a mounted file
  • Drop-in overrides via /etc/postgresql/conf.d/*.conf (optional)
  • Multi-arch support (amd64, arm64)

⁠Quickstart

docker run \
 -e POSTGRES_PASSWORD=mysecretpassword \
 ethoslink/postgres-backrest:latest

⁠Configuration

⁠PostgreSQL Configuration

The image ships with a default /etc/postgresql/postgresql.conf.

For anything beyond a couple of settings, the recommended practice is to provide a real Postgres config file (for example one generated by https://pgtune.leopard.in.ua⁠) and mount it into the container.

⁠Option A (simplest): replace the default config
  1. Generate a config on pgtune.
  2. Save it as postgresql.conf.
  3. Mount it to /etc/postgresql/postgresql.conf.

Example (docker run):

docker run \
 -e POSTGRES_PASSWORD=mysecretpassword \
 -v "$PWD/postgresql.conf:/etc/postgresql/postgresql.conf:ro" \
 ethoslink/postgres-backrest:latest
⁠Option B: mount the config elsewhere and point Postgres at it

Set POSTGRES_CONFIG_FILE to the file you mounted:

docker run \
 -e POSTGRES_PASSWORD=mysecretpassword \
 -e POSTGRES_CONFIG_FILE=/etc/postgresql/pgtune/postgresql.conf \
 -v "$PWD/postgresql.conf:/etc/postgresql/pgtune/postgresql.conf:ro" \
 ethoslink/postgres-backrest:latest

The shipped postgresql.conf includes include_dir = 'conf.d', so you can mount a small snippet without replacing the full file:

docker run \
 -e POSTGRES_PASSWORD=mysecretpassword \
 -v "$PWD/overrides.conf:/etc/postgresql/conf.d/overrides.conf:ro" \
 ethoslink/postgres-backrest:latest
⁠Notes
  • PostgreSQL doesn't provide a standardized set of environment variables for tuning knobs like shared_buffers, work_mem, effective_cache_size, etc. The established approach is to manage postgresql.conf (and optionally conf.d snippets) as configuration artifacts.
  • If you use container memory limits, treat pgtune output as a baseline and validate values against your runtime limits.
⁠Extra knobs supported by this image
  • POSTGRES_CONFIG_FILE (default: /etc/postgresql/postgresql.conf)
  • POSTGRES_HBA_FILE (default: /etc/postgresql/pg_hba.conf)

These are used to inject -c config_file=... and -c hba_file=... when the container is started with the postgres command.

⁠PgBackRest Configuration

On startup, the container renders /etc/pgbackrest/pgbackrest.conf from the template at /usr/local/share/pgbackrest/pgbackrest.conf.template using envsubst.

The default template is intentionally minimal and local-by-default. To customize PgBackRest behavior (including S3/R2/backends, retention, compression, etc.), provide your own template by mounting it into the container at:

  • /usr/local/share/pgbackrest/pgbackrest.conf.template

See the shipped template in this repo at postgres-backrest/pgbackrest.conf.template.

Common env vars referenced by the default template:

  • PGBACKREST_REPO1_PATH
  • PGBACKREST_REPO1_RETENTION_FULL
  • PGBACKREST_REPO1_RETENTION_DIFF
  • PGBACKREST_PROCESS_MAX
  • PGBACKREST_LOG_LEVEL_CONSOLE
  • PGBACKREST_LOG_LEVEL_FILE
  • PGBACKREST_LOG_PATH
  • PGBACKREST_COMPRESS_TYPE
  • PGBACKREST_COMPRESS_LEVEL
  • PGBACKREST_PG1_PATH

⁠Building

To build the image with a specific PostgreSQL version:

docker build --build-arg POSTGRES_VERSION=18.1 -t ethoslink/postgres-backrest:18.1 .

⁠Security & Maintenance

The image is based on the official Debian-based PostgreSQL image and installs pgbackrest from the official apt repositories.

  • Updates: Images are immutable. To get security updates, pull a newer tag.
  • Scanning: We run Trivy⁠ scans on every build to monitor for vulnerabilities.

⁠Publishing

The image is published to:

  • Docker Hub: ethoslink/postgres-backrest
  • GitHub Container Registry: ghcr.io/ethos-link/postgres-backrest

To update to a new PostgreSQL version, pass a different POSTGRES_VERSION build-arg (or change the Dockerfile default) and rebuild.

⁠License

MIT

Tag summary

Content type

Image

Digest

sha256:6c8573fd1…

Size

156.5 MB

Last updated

3 months ago

docker pull ethoslink/postgres-backrest