Last active
March 3, 2022 07:44
-
-
Save arvindkumarbadwal/c3b902f522247d1997c58d8dbcc0d43a to your computer and use it in GitHub Desktop.
Postgres Command to Dump or Restore File in Docker without Owner & Privileges
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Dump a PostgreSQL database into a file | |
-- container_name - PostgreSQL container name | |
-- db_user - user name to connect as. | |
-- db_name - name of the database to be dumped | |
-- -O - no-owner | |
-- -x - no-privileges | |
-- | |
docker exec -i [container_name] pg_dump --username [db_user] [db_name] -O -x > dump.sql | |
-- | |
-- Restore/Import a PostgreSQL database into a file | |
-- | |
docker exec -i [container_name] pg_dump --username [db_user] [db_name] < dump.sql | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment