PostgreSQL + script backup/restore
1.8K
This image is based on postgres:${PHP_VER}-alpine3
but with the ability to conveniently create dumps and restore from them.
Published on Docker Hub
Dumps are stored in the /backup folder.
To access the created dumps, you need to mount external storage:
-v ./dump:/backup
Example docker compose
services:
db:
build: .
container_name: docker_db_pgsql
restart: always
volumes:
- "./db:/var/lib/postgresql/data"
- "./dump:/backup"
environment:
POSTGRES_DB: ${DB_DATABASE}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
dumpTo create a backup from the database in the current container:
If using docker
docker exec -it <container name> dump
If created via docker compose
docker compose exec <service name> dump
restoreTo load a dump into the container, copy it to the mounted disk or start the container and copy it with the command:
docker cp <path to file> <container>:/backup/<dump name>
If using docker
docker exec -it <container name> restore
If created via docker compose
docker compose exec <service name> restore
Then choose one of the existing dumps.
Same as in the parent postgres image
Required. Sets the password for the main user on first container start.
Creates the main user on first container start.
If not specified, it will be postgres.
Creates a database with this name on first container start.
If not specified, it will equal POSTGRES_USER.
Content type
Image
Digest
sha256:0154dc601…
Size
106.3 MB
Last updated
8 months ago
docker pull leadsdoit/postgres