Image to create PostgreSQL database backups daily
368
We have created an image to be used to create backups of your PostgreSQL database. The backups can then be restored using an external tool, e.g. pgAdmin or DBeaver.
This image should be used as a container on itself. However, it's most likely you have a PostgreSQL database in your environment as well.
The image has a few variables that are required and a few that are optional.
| Environment variable | Required | Default value | Description |
|---|---|---|---|
| POSTGRES_HOST | Yes | - | The hostname of the PostgreSQL database. In a Docker environment, the name of the container. |
| POSTGRES_DB | Yes | - | The database name. |
| POSTGRES_USER | Yes | - | The username. |
| POSTGRES_PASSWORD | Yes | - | The password. |
| SCHEDULE | No | 0 2 * * * | The schedule of the backup task, in a cron-format. |
| DAILY_RETENTION | No | 7 | The number of daily backups to retain. |
| WEEKLY_RETENTION | No | 4 | The number of weekly backups to retain. |
| MONTHLY_RETENTION | No | 12 | The number of monthly backups to retain. |
To use this image, we can use it like the following in the Docker compose file:
pg-backup:
image: mypoiworld/pg-backup:18
depends_on:
- postgresql # The name of the postgresql container, if you have one
environment:
POSTGRES_HOST: hostname
POSTGRES_DB: db-name
POSTGRES_USER: username
POSTGRES_PASSWORD: password
# backup every hour on the hour
SCHEDULE: "0 0/1 * * *"
volumes:
- "./postgresdata/backups:/backups"
Content type
Image
Digest
sha256:3f5113d03…
Size
106.8 MB
Last updated
7 months ago
docker pull mypoiworld/pg-backup:18