docker exec mydb pg_dump -U postgres appdb > appdb.sql

Category: Docker

docker exec mydb pg_dump -U postgres appdb > appdb.sql

Dump a database running inside a container

Runs pg_dump inside the mydb container and redirects the SQL to a local file for backup. The redirect happens on the host, so the file lands locally. Restore with psql or pg_restore later.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.