Docker image that copies data from DatabaseA to DatabaseB using pg_dump and psql
Basically, I do a pg_dump
from DatabaseA and restore the dump, with psql
on DatabaseB
The pg_copy image uses several environment variables which are easy to miss.
Warning: All the variables are required, the container wouldn't work without them
The postgres DSN to the database that you want to copy
example:
POSTGRES_DB_A_DSN: "postgresql://postgres:example@db:5432/postgres"
The postgres DNS to the database that you want to load the data from POSTGRES_DB_A_DSN
example:
POSTGRES_DB_B_DSN: "postgresql://postgres:example@db:5432/lorn"
If you want to test the pg_copy
locally, you can use docker-compose
:
Clone the repo and docker-compose run --service-ports pg_copy
You need to run docker-compose run
two times because of the postgresql initialization bootstrap