Alex's Slip-box

These are my org-mode notes in sort of Zettelkasten style

pg_dump

:ID: A7B098E7-2E2E-48C8-9553-48E08727FA38

# Basic example

Use this in order to restore by using psql. See also psql for how to restore.

pg_dump --dbname mydatabase --no-owner --no-privileges --file dump.sql

# Using pg_restore?

Use the -Fc flag (format-custom) to dump to a file whose format is suitable for using pg_restore.

When using pg_restore you can use some of the same flags, like --data-only if you don’t want to restore schema. Also, --disable-triggers can be useful if you need to skip constraint checks.

# Only want data?

Use --data-only flag.

# Only want certain tables?

Use -t flag (this matches against a pattern, so you can use * wildcards)

pg_dump --dbname mydatabase --no-owner --no-privileges -t users --file dump.sql

# Need to specify connection details?

Use the same flags as you would with psql

pg_dump -h localhost -p 9001 -U postgres -d mydatabase -Fc --file dump.sql

Search Results