Skip to content

Instantly share code, notes, and snippets.

@ArthurDelannoyazerty
Created March 26, 2025 11:14
Show Gist options
  • Save ArthurDelannoyazerty/575573a0f09769a49ff4f70fe96b0aeb to your computer and use it in GitHub Desktop.
Save ArthurDelannoyazerty/575573a0f09769a49ff4f70fe96b0aeb to your computer and use it in GitHub Desktop.
postgres use of pg_dump and pg_restore

General info

  • pg_dump : Database to file
  • pg_restore : file to Database
  • Better if pg_restore --version > pg_dump --version

pg_dump

pg_dump -f /pg_dump.dump -Fc --dbname DB_NAME -U USERNAME

  • -Fc : Format=custom

pg_restore

pg_restore --dbname DB_NAME -c -C -O --no-acl -U USERNAME /pg_dump.dump

  • -c : Drop the database objects
  • -C : Create the table
  • -O : Skip object ownership restoration
  • --no-acl : exclude any access control lists (???)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment