How to do it...

Use the following steps to back up a database:

  1. Start backing up the chapter10 database by executing the following command:
      > pg_dump -f chapter10.backup -F custom chapter10

We use the -f flag to specify that the backup should be placed in the chapter10.backup file. We also use the -F flag to set the format of the backup output as custom - the most flexible and compressed of pg_dump's output formats by default.

  1. Inspect the backup file by outputting the contents onto a SQL file by executing the following command:
      > pg_restore -f chapter10.sql chapter10.backup

After creating a backup, it is good practice to make sure that the backup is valid. We do so with the pg_restore PostgreSQL tool. The -f flag instructs pg_restore ...

Get PostGIS Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.