Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a Postgresql Dump from a Docker container?

I would like to have a way to enter into the Postgresql container and get a data dump from it.

like image 932
Cesar Augusto Nogueira Avatar asked May 11 '15 14:05

Cesar Augusto Nogueira


People also ask

How does Docker integrate with PostgreSQL?

Fill the port value as 5432 that runs the Docker PostgreSQL Container and provide the name of the database as postgres. Then, fill the username and password fields with the credentials you created while running the PGAdmin container. After providing all required details, click on the “Save” button.


1 Answers

Use the following command from a UNIX or a Windows terminal:

docker exec <container_name> pg_dump <schema_name> > backup 

The following command will dump only inserts from all tables:

docker exec <container_name> pg_dump --column-inserts --data-only  <schema_name> > inserts.sql 
like image 83
Cesar Augusto Nogueira Avatar answered Sep 27 '22 19:09

Cesar Augusto Nogueira