Sign inSign up

tractr/postgres-backup

By tractr

Updated over 3 years ago

https://github.com/tractr/docker-images/tree/main/backups/postgres

Image
0

2.8K

tractr/postgres-backup repository overview

Using a prepost strategy to create Postgres backups

Volumerize can execute scripts before and after the backup process.

With this prepost strategy you can create a .sql backup of your Postgres containers and save it with Volumerize.

Environment Variables

Aside of the required environment variables by Volumerize, this prepost strategy will require a couple of extra variables.

NameDescription
POSTGRES_USERUsername of the user who will perform the restore or dump.
POSTGRES_PASSWORDPassword of the user who will perform the restore or dump.
POSTGRES_HOSTIP or domain of the host machine.
POSTGRES_PORTPort to use. Default: 5432
POSTGRES_DBDatabase to backup / restore.

Example with Docker Compose

version: "2"

services:
  postgres:
    image: postgres:13-alpine
    ports:
      - 5432:5432
    volumes:
      - postgres:/var/lib/postgresql/data/
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=1234
      - POSTGRES_DB=somedatabase

  volumerize:
    image: tractr/postgres-backup
    environment:
      - VOLUMERIZE_SOURCE=/source
      - VOLUMERIZE_TARGET=file:///backup
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=1234
      - POSTGRES_HOST=postgres
      - POSTGRES_PORT=5432
      - POSTGRES_DB=somedatabase
    volumes:
      - volumerize-cache:/volumerize-cache
      - backup:/backup
    depends_on:
      - postgres

volumes:
  volumerize-cache:
  postgres:
  backup:

Then execute docker-compose exec volumerize backup to create a backup of your database and docker-compose exec volumerize restore to restore it from your backup.

Notes

You may see this output on restore:

Command was: DROP TABLE public.users;
pg_restore: warning: errors ignored on restore: 1

It is only a warning saying that the table to restore did not exist before restore.

Tag summary

Content type

Image

Digest

sha256:dfce1d9af

Size

490.3 MB

Last updated

over 3 years ago

docker pull tractr/postgres-backup