Dumps the database from a Postgres Docker container
- Docker installed on your machine
- A running Postgres Docker container
-
Clone the repository:
git clone https://github.com/goodpie/export-pg-db-docker.git cd export-pg-db-docker -
Run the script to dump the database:
./export-pg-db-docker.sh <container_name> <db_user> <db_name> [directory]
<container_name>: Name of the Docker container to pull the database from.<db_user>: Username for the PostgreSQL database.<db_password>: Password for the PostgreSQL database.
-
Run the script:
./import-pg-db-docker.sh <container_name> <db_user> <db_password> <db_name> [directory]
<container_name>: Name of the Docker container to be created.<db_user>: Username for the PostgreSQL database.<db_password>: Password for the PostgreSQL database.<db_name>: Name of the PostgreSQL database.[directory]: Optional directory to store or read the SQL dump file. If not provided, a temporary directory will be used.
-
Select the SQL dump file:
The script will list all available
.sqlfiles in the current directory. Enter the number corresponding to the file you want to use for the database import.
./export-pg-db-docker.sh my_old_container my_user my_password
./import-pg-db-docker.sh my_container my_user my_password my_databaseThis project is licensed under the MIT License.