Docker Pgbackrest

pgBackRest inside Docker.
Alternatives To Docker Pgbackrest
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Netdata65,170
15 hours ago359gpl-3.0C
Monitor your servers, containers, and applications, in high-resolution and in real-time!
Gogs42,92045 days ago74February 25, 2023873mitGo
Gogs is a painless self-hosted Git service
Plane16,144
6 hours ago220agpl-3.0TypeScript
🔥 🔥 🔥 Open Source JIRA, Linear and Height Alternative. Plane helps you track your issues, epics, and product roadmaps in the simplest way possible.
Full Stack Fastapi Postgresql12,908
13 days ago230mitPython
Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.
Coolify8,927
4 hours ago27apache-2.0PHP
An open-source & self-hostable Heroku / Netlify alternative. Cloud version available here -> https://app.coolify.io
Docker Gitlab7,643
3 days ago535mitShell
Dockerized GitLab
Pgloader4,693
11 days ago1February 27, 2018336otherCommon Lisp
Migrate to PostgreSQL in a single command!
Stolon4,295
17 days ago17September 03, 2021145apache-2.0Go
PostgreSQL cloud native High Availability and more.
Devilbox4,194
a month ago59mitPHP
A modern Docker LAMP stack and MEAN stack for local development
Dbmate3,78752 days ago37June 23, 202324mitGo
:rocket: A lightweight, framework-agnostic database migration tool.
Alternatives To Docker Pgbackrest
Select To Compare


Alternative Project Comparisons
Readme

docker-pgbackrest

Actions Status

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.47, latest
  • 2.47-alpine
  • 2.46
  • 2.46-alpine
  • 2.45
  • 2.45-alpine
  • 2.44
  • 2.44-alpine
  • 2.43
  • 2.43-alpine

The repository also contains information for releases of pgBackRest fork with Greenplum support (see pgbackrest/pull/1833). Details - build with Greenplum support.

Supported pgBackRest version tags with Greenplum support:

  • 2.47-gpdb
  • 2.47-gpdb-alpine
  • 2.45-gpdb
  • 2.45-gpdb-alpine
  • 2.40-gpdb
  • 2.40-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, default Etc/UTC;
  • BACKREST_USER - non-root user name for execution of the command, default pgbackrest;
  • BACKREST_UID - UID of internal ${BACKREST_USER} user, default 2001;
  • BACKREST_GROUP - group name of internal ${BACKREST_USER} user, default pgbackrest;
  • BACKREST_GID - GID of internal ${BACKREST_USER} user, default 2001;
  • BACKREST_HOST_TYPE - repository host protocol type, default ssh, available values: ssh, tls;
  • BACKREST_TLS_WAIT - waiting for TLS server startup in seconds when BACKREST_HOST_TYPE=tls, default 15;
  • BACKREST_TLS_SERVER - start container as pgBackRest TLS server, default disable, available values: disable, enable.

Pull

Change tag to to the version you need.

  • Docker Hub:
docker pull woblerr/pgbackrest:tag
docker pull woblerr/pgbackrest:tag-alpine
  • GitHub Registry:
docker pull ghcr.io/woblerr/pgbackrest:tag
docker pull ghcr.io/woblerr/pgbackrest:tag-alpine

Run

You will need to mount the necessary directories or files inside the container (or use this image to build your own on top of it).

Simple

docker run --rm  pgbackrest:2.47 pgbackrest help

Injecting inside

docker run --rm -it pgbackrest:2.47 bash

pgbackrest@cac1f58b56f2:/$ pgbackrest version
pgBackRest 2.47

Example for Dedicated Repository Host

Host USER:GROUP - pgbackrest:pgbackrest, UID:GID - 1001:1001. Backups are stored locally under the user pgbackrest.

Use SSH

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.47 \
    pgbackrest backup --stanza demo --type full --log-level-console info

And 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 info

To 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.47 \
    pgbackrest backup --stanza demo --type full --log-level-console info

Use TLS

Available 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_TYPE and BACKREST_TLS_WAIT do 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 after 15 seconds.

    The variable should be BACKREST_TLS_SERVER=disable.

TLS server configuration is described in the pgBackRest documentation.

Run container as pgBackRest TLS server
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.47
Run container with TLS server in background for pgBackRest execution over TLS
docker 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.47 \
    pgbackrest backup --stanza demo --type full --log-level-console info

Example for backup to local path for PostgreSQL running locally in Chicago

PostgreSQL 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.47 \
    pgbackrest backup --stanza demo --type full --log-level-console info

Example for backup to local path for PostgreSQL running remote over TLS

PostgreSQL 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.47

Performing 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.47 \
    pgbackrest backup --stanza demo --type full --log-level-console info

Build

make build_version TAG=2.47
make build_version_alpine TAG=2.47

or

docker build -f Dockerfile --build-arg BACKREST_VERSION=2.47 --build-arg BACKREST_COMPLETION_VERSION=v0.9 -t pgbackrest:2.47 .
docker build -f Dockerfile.alpine --build-arg BACKREST_VERSION=2.47 --build-arg BACKREST_COMPLETION_VERSION=v0.9 -t pgbackrest:2.47-alpine .

Build with Greenplum support

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.

Pull

Change tag to to the version you need.

  • Docker Hub:
docker pull woblerr/pgbackrest:tag-gpdb
docker pull woblerr/pgbackrest:tag-gpdb-alpine
  • GitHub Registry:
docker pull ghcr.io/woblerr/pgbackrest:tag-gpdb
docker pull ghcr.io/woblerr/pgbackrest:tag-gpdb-alpine

Run

docker run --rm  pgbackrest:2.47-gpdb pgbackrest help

Running tests

Run the end-to-end tests:

make test-e2e

See tests description.

Popular Docker Projects
Popular Postgresql Projects
Popular Virtualization Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Shell
Docker
Postgresql
Backup