Table of Contents

pg_dump

Tips

Examples

Dump all tables, with acl/permissions, with create table scripts, to a plain text file (note that -d means to use INSERT statements instead of COPY statements, not to specify a db) with sql commands:

pg_dump --file=/path/to/output/file.sql --no-owner --format=p \
--disable-triggers -h hostname -d database

Dump a single table, without create table script, without ownerships, to a compressed format suitable for pg_restore:

pg_dump --data-only --file=/path/to/output/file.sql --no-owner --format=t \
--table=sometable --no-privileges --disable-triggers -h hostname database

Dump database schema, without owners or permissions:

pg_dump --schema-only --no-owner --no-privileges -h hostname -U username databasename > dumpfile.sql