To perform a backup of a PostgreSQL database running in a Docker container, you can use the pg_dump command to export the database to a SQL script file, and then use the docker cp command to copy the file from the container to your local machine.
For example, assuming that your PostgreSQL container is named “my-Postgres”, you could use the following pg_dump command to export the contents of the “mydb” database to a file named “mydb.sql”:
docker exec my-postgres pg_dump mydb > mydb.sql
This will create a file named “mydb.sql” in the current directory on the host machine, containing the SQL commands needed to recreate the “mydb” database.
Top comments (0)