pgBackRest inside Docker can be useful for refusing to install pgBackRest as a system package (using yum or apt, for example) on your Dedicated Repository Host or inside CI/CD systems. You can just run pgBackRest in Docker. At the same time, the PostgreSQL server side must be configured according to the pgBackRest documentation.
The repository contains information for the last 5 releases of pgBackRest. If necessary to use an older version - do a manual build.
Supported pgBackRest version tags:
2.57.0,latest2.57.0-alpine2.56.02.56.0-alpine2.55.12.55.1-alpine2.55.02.55.0-alpine2.54.22.54.2-alpine
The repository also contains information for releases of pgBackRest fork with Greenplum support (see pgbackrest/pull/1833). Details - build with Greenplum support.
The repository contains information for the last 2 releases of pgBackRest fork with Greenplum support. If necessary to use an older version - do a manual build.
Supported pgBackRest version tags with Greenplum support:
2.54-gpdb2.54-gpdb-alpine2.52-gpdb2.52-gpdb-alpine
The image is based on the official ubuntu or alpine image. For ubuntu image each version of pgBackRest builds from the source code in a separate builder container. For alpine image each version of pgBackRest builds from the source code in container using virtual package .backrest-build.
The image contains pgbackrest-bash-completion script. You can complete pgbackrest commands by pressing tab key.
Environment variables supported by this image:
TZ- container's time zone, defaultEtc/UTC;BACKREST_USER- non-root user name for execution of the command, defaultpgbackrest;BACKREST_UID- UID of internal${BACKREST_USER}user, default2001;BACKREST_GROUP- group name of internal${BACKREST_USER}user, defaultpgbackrest;BACKREST_GID- GID of internal${BACKREST_USER}user, default2001;BACKREST_HOST_TYPE- repository host protocol type, defaultssh, available values:ssh,tls;BACKREST_TLS_WAIT- waiting for TLS server startup in seconds whenBACKREST_HOST_TYPE=tls, default15;BACKREST_TLS_SERVER- start container as pgBackRest TLS server, defaultdisable, available values:disable,enable.
Change tag to to the version you need.
- Docker Hub:
docker pull woblerr/pgbackrest:tagdocker pull woblerr/pgbackrest:tag-alpine- GitHub Registry:
docker pull ghcr.io/woblerr/pgbackrest:tagdocker pull ghcr.io/woblerr/pgbackrest:tag-alpineYou will need to mount the necessary directories or files inside the container (or use this image to build your own on top of it).
docker run --rm pgbackrest:51 pgbackrest helpdocker run --rm -it pgbackrest:2.57.0 bash
pgbackrest@cac1f58b56f2:/$ pgbackrest version
pgBackRest 2.57.0Host USER:GROUP - pgbackrest:pgbackrest, UID:GID - 1001:1001. Backups are stored locally under the user pgbackrest.
docker run --rm \
-e BACKREST_UID=1001 \
-e BACKREST_GID=1001 \
-v ~/.ssh/id_rsa:/home/pgbackrest/.ssh/id_rsa \
-v /etc/pgbackrest:/etc/pgbackrest \
-v /var/lib/pgbackrest:/var/lib/pgbackrest \
pgbackrest:2.57.0 \
pgbackrest backup --stanza demo --type full --log-level-console infoAnd and the same time for old pgBackRest version:
docker run --rm \
-e BACKREST_UID=1001 \
-e BACKREST_GID=1001 \
-v ~/.ssh/id_rsa:/home/pgbackrest/.ssh/id_rsa \
-v /etc/pgbackrest:/etc/pgbackrest \
-v /var/lib/pgbackrest:/var/lib/pgbackrest \
pgbackrest:2.30 \
pgbackrest backup --stanza demo-old --type full --log-level-console infoTo exclude simultaneous execution of multiple backup processes for one stanza:
docker run --rm \
-e BACKREST_UID=1001 \
-e BACKREST_GID=1001 \
-v ~/.ssh/id_rsa:/home/pgbackrest/.ssh/id_rsa \
-v /etc/pgbackrest:/etc/pgbackrest \
-v /var/lib/pgbackrest:/var/lib/pgbackrest \
-v /tmp/pgbackrest:/tmp/pgbackrest \
pgbackrest:2.57.0 \
pgbackrest backup --stanza demo --type full --log-level-console infoAvailable only for pgBackRest version >= 2.37.
There are two mode for using TLS for communication.
-
Run container as pgBackRest TLS server.
You need to set
BACKREST_TLS_SERVER=enable.The variables
BACKREST_HOST_TYPEandBACKREST_TLS_WAITdo not affect this startup mode. -
Run container with TLS server in background for pgBackRest execution over TLS.
You need to set
BACKREST_HOST_TYPE=tls.Using
BACKREST_TLS_WAIT, you can change the TLS server startup waiting. By default, checking that the TLS server is running will be performed after15 seconds.The variable should be
BACKREST_TLS_SERVER=disable.
TLS server configuration is described in the pgBackRest documentation.
docker run -d \
-e BACKREST_UID=1001 \
-e BACKREST_GID=1001 \
-e BACKREST_TLS_SERVER=enable \
-v /etc/pgbackrest:/etc/pgbackrest \
-v /var/lib/pgbackrest:/var/lib/pgbackrest \
-p 8432:8432 \
--name backrest_server \
pgbackrest:2.57.0docker run --rm \
-e BACKREST_UID=1001 \
-e BACKREST_GID=1001 \
-e BACKREST_HOST_TYPE=tls \
-v /etc/pgbackrest:/etc/pgbackrest \
-v /var/lib/pgbackrest:/var/lib/pgbackrest \
pgbackrest:2.57.0 \
pgbackrest backup --stanza demo --type full --log-level-console infoPostgreSQL run from user postgres:postgres with UID:GID 1001:1001. PostgreSQL data path - /var/lib/postgresql/12/main, pgBackRest backup path - /var/lib/pgbackrest.
docker run --rm \
-e BACKREST_USER=postgres \
-e BACKREST_UID=1001 \
-e BACKREST_GROUP=postgres \
-e BACKREST_GID=1001 \
-e TZ=America/Chicago \
-v /etc/pgbackrest/pgbackrest.conf:/etc/pgbackrest/pgbackrest.conf \
-v /var/lib/postgresql/12/main:/var/lib/postgresql/12/main \
-v /var/lib/pgbackrest:/var/lib/pgbackrest \
-v /var/run/postgresql/.s.PGSQL.5432:/var/run/postgresql/.s.PGSQL.5432 \
pgbackrest:2.57.0 \
pgbackrest backup --stanza demo --type full --log-level-console infoPostgreSQL run on remote host. Сommunication between hosts via TLS. pgBackRest path for backup and WAL files - /var/lib/pgbackrest.
Run the container as a TLS server. After that, remote PostgreSQL will be able to archive WAL files.
docker run -d \
-e BACKREST_UID=1001 \
-e BACKREST_GID=1001 \
-e BACKREST_TLS_SERVER=enable \
-v /etc/pgbackrest/pgbackrest.conf:/etc/pgbackrest/pgbackrest.conf \
-v /etc/pgbackrest/cert:/etc/pgbackrest/cert \
-v /var/lib/pgbackrest:/var/lib/pgbackrest \
-p 8432:8432 \
--name backrest_server \
pgbackrest:2.57.0Performing a backup:
docker run --rm \
-e BACKREST_UID=1001 \
-e BACKREST_GID=1001 \
-e BACKREST_HOST_TYPE=tls \
-v /etc/pgbackrest/pgbackrest.conf:/etc/pgbackrest/pgbackrest.conf \
-v /etc/pgbackrest/cert:/etc/pgbackrest/cert \
-v /var/lib/pgbackrest:/var/lib/pgbackrest \
pgbackrest:2.57.0 \
pgbackrest backup --stanza demo --type full --log-level-console infomake build_version TAG=2.57.0make build_version_alpine TAG=2.57.0or
docker build -f Dockerfile --build-arg BACKREST_VERSION=2.57.0 --build-arg BACKREST_COMPLETION_VERSION=v0.10 -t pgbackrest:2.57.0 .docker build -f Dockerfile.alpine --build-arg BACKREST_VERSION=2.57.0 --build-arg BACKREST_COMPLETION_VERSION=v0.10 -t pgbackrest:2.57.0-alpine .Since version v2.51, the build system for pgBackRest is meson. The autoconf/make build will not receive any new features and will be removed in future. If you need to build pgBackRest lower than v2.51, use the files Dockerfile_make or Dockerfile_make.alpine.
make build_version TAG=2.49make build_version_alpine TAG=2.49or
docker build -f Dockerfile_make --build-arg BACKREST_VERSION=2.49 --build-arg BACKREST_COMPLETION_VERSION=v0.10 -t pgbackrest:2.49 .docker build -f Dockerfile_make.alpine --build-arg BACKREST_VERSION=2.49 --build-arg BACKREST_COMPLETION_VERSION=v0.10 -t pgbackrest:2.49-alpine .PR pgbackrest/pull/1833 is still not merged into pgBackRest. The separate tags *-gpdb are used for pgBackRest images with Greenplum support. When the PR is accepted, separate tags will no longer be needed.
The image completely repeats all the possibilities of the image for pgBackRest.
Change tag to to the version you need.
- Docker Hub:
docker pull woblerr/pgbackrest:tag-gpdbdocker pull woblerr/pgbackrest:tag-gpdb-alpine- GitHub Registry:
docker pull ghcr.io/woblerr/pgbackrest:tag-gpdbdocker pull ghcr.io/woblerr/pgbackrest:tag-gpdb-alpinedocker run --rm pgbackrest:2.54-gpdb pgbackrest helpIf you need to build pgBackRest with Greenplum support lower than v2.51, use the files Dockerfile_make or Dockerfile_make.alpine.
Run the end-to-end tests:
make test-e2eSee tests description.