truii/postgres-backup

By truii

Updated 7 months ago

Image
Databases & Storage
Monitoring & Observability

74

pgbackup docker image

This docker image is built for both AMD64 and ARM64 architectures, allowing native execution on local M1/2/3 macos devices.

The following commands are used to build the images for both PG16 and PG13 on the archs listed above:

➜ docker buildx build --platform=linux/amd64,linux/arm64 . -t truii/postgres-backup:16

And for PG13, we need to specify a different ALPINE_VERSION variable (along with the PGVERSION env) to build without errors:

➜ docker buildx build --platform=linux/amd64,linux/arm64 . -t truii/postgres-backup:13 --build-arg ALPINE_VERSION=3.15 --build-arg PGVERSION=13

The image is available publicallyhere. There is no proprietary Truii code/secrets so there is no harm in making the image public. Because the image is built on the alpine plugin and installs the pg-client tools, the overall image is small meaning that docker can download the image in seconds. ~6MB for PG13 and ~8MB for PG16.

NOTE

The output format of the dumps is a tar format. Support for customising the output format is not planned at this stage.

Features

  • Support for dumping multiple databases with the use of the DATABASES env variable
  • Support for customising the output folder location of the dumps (default: /home)
  • Dumps are organised into datetime stamped folders (eg: YYYY-MM-DD_HH:MM)

Usage

To run this image, you will need to specify the following env variables (at a minimum):

  • DATABASES - a comma separated list of database names to backup
  • PGPASSWORD - the password to the user to authenticate to postgres
  • PGUSER - the user to authenticate to postgres
  • PGHOST - the fully qualified domain name (fqdn) or ip address of the postgres host
  • OUTPUT_PATH - (optional) change the location of the dump(s) location (default: /home)

Docker Pull Command

docker pull truii/postgres-backup