DATABASE » SQL » POSTGRESQL

Backup

Syntax

Extract a PostgreSQL database into a script file or other archive file.

shell
pg_dump CONNECTION_OPTIONS OPTIONS DBNAME
OptionDescription
-a --data-onlyDump only the data, not the schema (data definitions).
-F --formatSelects the format of the output. Any of plain (default) custom directory tar

Examples

Dump database into a plain-text file:

shell
pg_dump dbname > backup.sql

Dump a database into a custom-format archive file:

shell
pg_dump -Fc dbname > dbname.dump