Logical backups in PostgreSQL can be taken using pg_dump. These backups are portable across different operating systems and versions. Consider an example of moving a database from one server to another in order to upgrade it from PostgreSQL 9.6.x to PostgreSQL 13.x. In this case, we could use the binaries of PostgreSQL 13 to back up the database in version 9.6 and restore it using the version 13 binaries.
A backup taken using pg_dump can exist in both a text file (human-readable script file) format or a custom format (compressed). If a backup is taken in a plain text format, then we use psql to restore it. If a backup is taken in the custom format, then pg_restore must be used to restore that backup.
pg_dump helps in taking a consistent snapshot of the database without causing any waits to the usual database traffic. However, there are certain things to remember before considering a pg_dump for your backup strategy:
- pg_dump...