pg_dump
Extract a PostgreSQL database into a script file or other archive file. tldr-pages
On several platforms
Several platforms
Dump database into an SQL-script file
pg_dump db_name >output_file.sqlIdentifyDump a database into an SQL-script file, using a specific username
pg_dump --username username db_name >output_file.sqlIdentifyDump a database into an SQL-script file, using a specific host and port
pg_dump --host host --port port db_name >output_file.sqlIdentifyDump a database into a custom-format archive file
pg_dump --format [c db_name >output_file.dumpIdentifyDump only database data into an SQL-script file
pg_dump --data-only db_name >path/to/output_file.sqlIdentifyDump only schema (data definitions) into an SQL-script file
pg_dump --schema-only db_name >path/to/output_file.sqlIdentify