DEV Community


Posted on

Docker PostgreSQL Backup

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.

read full:

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git