Skip to content

Instantly share code, notes, and snippets.

@ddrscott
Created December 6, 2022 22:51
Show Gist options
  • Save ddrscott/626e84b63d56345670e44edb66e2e53d to your computer and use it in GitHub Desktop.
Save ddrscott/626e84b63d56345670e44edb66e2e53d to your computer and use it in GitHub Desktop.
version: '3'
services:
db:
image: postgres:11
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=secret
volumes:
- database-data:/var/lib/postgresql/data/
- .:/app
ports:
- '5432:5432'
volumes:
database-data:
$!/bin/sh
# start up database
docker compose up -d
# create target database
docker compose exec -T db psql -U postgres <<SQL
CREATE DATABASE postfacto;
SQL
# put the binary dump into created database
docker compose exec db pg_restore -Fc \
-d postfacto \
--verbose \
--clean \
--no-acl --no-owner \
-U postgres \
/app/541bd2d9-222d-4918-97c5-f8a5548890bf.pgdump
# get the binary dump out as plain SQL
docker compose exec db pg_dump \
-d postfacto \
--verbose \
--clean \
--no-acl --no-owner \
-U postgres \
| gzip -c > dump.sql.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment