Exporting data using the PostgreSQL backup functionality
In the chapter on data importing techniques, I mentioned that the built-in PostgreSQL backup utilities can also be used as data transfer tools. It does, of course, depend on the scenario we are working on, but in many cases passing data as a database backup file may be a valid and reliable solution.
Note
Obviously, saving a backup does not output the data in a form consumable by other software packages - only by Postgres itself.
pg_dump
is the utility that provides the database backup functionality. In order to get some help with it, type the following in the command line:
pg_dump --help
A great thing about pg_dump
is that it allows for great flexibility when backing up a database. One can dump a whole database, a single schema, multiple schemas, a single table, or multiple tables; it is even possible to exclude specified schemas or tables.
This approach is great, for example, for scenarios where the main database should remain within a...