Created
December 6, 2022 22:51
-
-
Save ddrscott/626e84b63d56345670e44edb66e2e53d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$!/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