Postgres official image containing backup script
4.8K
This image includes script for backing up all databases that are created inside Postgres Instance. Script is taken from here. Please check there for explanation how backup is working.
pg_backup_rotated.sh file is added to the image, and config file pg_backup.config has to be provided while starting backup docker container, since every installation can have different setup.
A prebuilt container is available on Docker Hub, you can get it with following command
docker pull inovatrend/postgres-backup
To run backup, following command can be used:
docker run --rm --interactive -v /data/tmp:/data/tmp --link docker-postgres:docker-postgres inovatrend/postgres-backup bash -c 'exec /pg_backup_rotated.sh -c /data/tmp/pg_backup.config'
BACKUP_DIR
Backup dir will usually be pointing to host directory mounted as data volume. In example above, BACKUP_DIR should have following value:
BACKUP_DIR=/data/tmp/
HOSTNAME
In pg_backup.config file special care has to be taken about HOSTNAME parameter. This parameter points to host where postgres is installed. Since Postgres is installed in Docker container, features of container linking will be used to properly configure backup script. For example, if you named configured link as in example above, then HOSTNAME property in pg_backup.config should look like this:
HOSTNAME=$DOCKER_POSTGRES_PORT_5432_TCP_ADDR
Content type
Image
Digest
sha256:3d870bb29…
Size
95.2 MB
Last updated
almost 11 years ago
docker pull inovatrend/postgres-backup