

When using archive formats, several command-line options supported by pg_dump are ignored, but can be specified when restoring the snapshot with the pg_restore command-line utility. The directory format also supports parallel snapshot creation and restoration (specified by the -j option). The archive file formats directory -Fd and custom -Fc are compressed by default and allow for selective restores of the data contained in the snapshot. More robust database snapshot and restore capabilities are provided by archive file formats. Several command-line options supported by pg_dump are ignored when using archive formats but can be specified when restoring the snapshot with pg_restore. The directory format also supports creating and restoring snapshots in parallel (specified by the -j parameter), which is why it is included in the recommended command above.

The directory (-Fd) and custom (-Fc) archive file formats are compressed by default and offer selective restores of the data contained in the snapshot. While the plain-text output format can potentially be used on other SQL database products (with some modifications), its speed and capabilities are limited.Īrchive file formats provide more robust database snapshot and restore capabilities. The default option -Fp generates a plain-text SQL script file that can be used to rebuild the database. The pg_dump utility supports a few different output formats for the database snapshot specified by the -F format command-line option. Will I be able to load a database snapshot created by a given version of pg_dump onto a given version of PostgreSQL server?.Will a version of pg_dump allow me to create a snapshot from a given version of PostgreSQL server?.The compatibility matrix answers the following questions: The compatibility matrix below will help you determine whether different versions of pg_dump, the database snapshot, and the PostgreSQL server will work together. The pg_dump utility will create this directory and it must not already exist. f Specifies the name of the target directory where the snapshot output will be saved. This option supports parallel snapshots (as specified by the -j option) and adds flexibility and selectivity when restoring a snapshot using the pg_restore utility. The database snapshot will be saved in this directory, with one file for each table included. Fd Selects directory format as the snapshot operation's output. This necessitates opening 8 + 1 database connections, so adjust the the server's max connections setting accordingly. In this case, we are taking snapshots of eight (8) tables at the same time. j 8 Indicates that we want to use parallelization to speed up the generation of the database snapshot. This is a convenient way to specify all database connection information in a single parameter. d ""Specifies the source database in URL format. TL DR - The pg_dump command with recommended optionsįor those readers that want to get right to the answer, here is the pg_dump command with recommended options. Snapshots created in archive format are restored with pg_restore. Generating a snapshot in plain-text format can be restored using the psql utility.At a minimum, you'll need SELECT privileges on the database you wish to snapshot. pg_dump executes SELECT statements to create the database snapshot.It does not block other users from reading or writing to the database. pg_dump makes consistent database snapshots, even if the database is being used concurrently.Some important things to know about pg_dump: The command-line utility used to create the PostgreSQL database snapshot is named pg_dump. This article is intended to present these options as well as a summary of important things to know when creating a PostgreSQL database snapshot.

For most use cases, there is a standard set of options that can be specified to quickly generate a flexible snapshot. The PostgreSQL snapshot and restore utilities come with a plethora of command-line options, giving you a great deal of control over what data is included and how the backup is performed. PostgreSQL includes a robust set of utilities for managing this task.

In this article we discuss the PostgreSQL pg_dump command and important things to know when creating a database snapshotĪ point-in-time database backup, also known as a database snapshot, is a common database development practice for backing up and transferring databases.
