pg_dump -Fc -f DATABASE.pgsql DATABASE
The -Fc
selects the "custom backup format" which gives you more power than raw SQL; see pg_restore
for more details. If you want a vanilla SQL file, you can do this instead:
pg_dump -f DATABASE.sql DATABASE
or even
pg_dump DATABASE > DATABASE.sql