TOWERBY CETMIX
← Hangar / jet_template_postgres_docker

Shared PostgreSQL in Docker with Optional pgBackRest Backups

Deploy a persistent PostgreSQL Jet for Odoo and other Docker services, with optional local and S3 backups.

↓ Download↓ 0 downloads

Summary

Category
Jet Templates
Tags
Database
Authors
Cetmix OÜ
License
AGPL-3
Version
1.0.0
Call sign
jet_template_postgres_docker

This snippet imports the Postgres Docker Jet Template. It runs one shared PostgreSQL instance per server, defaults to PostgreSQL 17, and builds a Jet-specific image from the selected PostgreSQL version. It includes Docker, Fail2ban and Tower Core dependency templates. Database files persist in a named Docker volume by default. Set shared_postgres_data to a host path to use a bind mount instead. Clients on the shared Tower Docker network connect to the Jet reference on port 5432. Set postgres_port only when a host-side port mapping is needed.

Configure and launch

  1. Import the YAML and install the Postgres Docker template on the target server. Set postgres_password in Tower Keys and Secrets and configure postgres_user (default odoo). Review the PostgreSQL version, data location and any tuning settings, such as postgres_shm_size or pg_max_connections.
  2. For backups, set install_pgbackrest to yes before Build. This configures WAL archiving, a local backup repository and an archive spool. To add an S3 repository, set s3_endpoint, aws_s3_bucket_name and aws_region along with the aws_key_id and aws_access_key secrets. The snippet passes these credentials as container environment variables and also renders them into the mounted pgBackRest configuration.
  3. Create a Jet targeting Running. Build prepares persistent storage, builds the image and creates the container. Start launches PostgreSQL and, when backups are enabled, checks the pgBackRest stanza and, when initialization is needed, creates it and takes an initial full backup. The included scheduled plan is configured to run incremental backups every eight hours when pgBackRest is enabled.

Operate and troubleshoot

Check Postgres logs and the Flight Plan output for startup or backup failures. If clients cannot connect, verify the Jet reference, Docker network and database credentials. For backup failures, check stanza status, WAL archiving and the configured repositories.

Stop stops dependent Odoo Jets before stopping PostgreSQL. Restart restarts PostgreSQL and then triggers a fast restart of dependent Odoo Jets. Rebuild recreates the stopped container while reusing its persistent storage and rendered build files. Remove removes the container and image. Destroy removes the Jet root and its labeled volumes, including the default database volume and local backup repository. If teardown manages a Cloudflare record for the Jet, it uses cloudflare_token and cloudflare_zone_id.