Creating base backups

After teaching PostgreSQL to archive those WAL files, it is time to create a first backup. The idea is to have a backup and to replay WAL files based on that backup to reach any point in time.

To create an initial backup, you can turn to pg_basebackup, which is a command-line tool used to perform backups. Let us call pg_basebackup and see how it works:

pg_basebackup -D /some_target_dir          -h localhost          --checkpoint=fast          --xlog-method=stream 

As you can see, I am using four parameters here:

  • -D: Where do you want the base backup to live? PostgreSQL requires an empty directory. At the end of the backup you will see a copy of the server's data directory there (destination).
  • -h: Indicates the IP address or the name of the ...

Get Mastering PostgreSQL 10 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.