Dump database into an SQL-script file

pg_dump

  • Extract a PostgreSQL database into a script file or other archive file.
    More information: <https://www.postgresql.org/docs/current/app-pgdump.html>.
  • Trick copyright: tl;dr; <https://github.com/tldr-pages/tldr>

pg_dump {{db_name}} > {{output_file.sql}}

click the source code to copy install pg_dump on any operating system with command-not-found.com