Skip to content

This is the multi-page printable view of this section. .

Return to the regular view of this page.

pgBackRest 2.59.2 Documentation

Reliable PostgreSQL Backup & Restore — pgBackRest documentation and reference.

Snapshot of the pgBackRest 2.59.2 documentation: https://pgbackrest.org/


Introduction

pgBackRest provides backup and restore functions for PostgreSQL. It supports large databases and workloads.

pgBackRest v2.59.2 is the current stable release. Release notes are on the Releases page.

If you like pgBackRest, give the project a star on GitHub.


News

September 27, 2026 - pgBackRest 2.59.2 Released

August 17, 2026 - pgBackRest 2.59.1 Released

July 20, 2026 - New Distribution Tarball


Sponsors

Sponsorship makes pgBackRest possible. New features, bug fixes, contribution reviews, community support, and maintenance require substantial time. If your enterprise uses pgBackRest, consider a sponsorship.

Our sponsors: AWS, Supabase, pgEdge, Tiger Data, Percona, Eon, Xata, Dalibo, and Data Egret.

We thank our sponsors for supporting open-source infrastructure for the PostgreSQL community.

Past sponsors: Crunchy Data, Resonate.


Features

Parallel Backup & Restore

Compression usually limits backup speed. pgBackRest uses parallel processing and efficient compression algorithms, such as lz4 and zstd, to reduce this limit.

Local or Remote Operation

A custom protocol lets pgBackRest back up, restore, and archive locally or remotely through TLS/SSH with minimal configuration. The protocol also provides an interface to query PostgreSQL. This interface removes the need for remote PostgreSQL access and improves security.

Multiple Repositories

You can use multiple repositories. For example, use a local repository with short retention for fast restores. Use a remote repository with longer retention for redundancy and access across the enterprise.

Full, Differential, & Incremental Backups (at File or Block Level)

pgBackRest supports full, differential, and incremental backups. It avoids the time resolution problems of rsync. Thus, differential and incremental backups are safe without a checksum calculation for each file. Block-level backups save space because they copy only the changed parts of files.

Backup Rotation & Archive Expiration

Set retention policies for full and differential backups to cover the required time frame. Keep the WAL archive for all backups or only the most recent backups. In the second case, the archive still keeps the WAL necessary to make older backups consistent.

Backup Integrity

pgBackRest calculates a checksum for every backup file. It checks each checksum again during a restore or verify operation. After it copies the backup files, it waits for all WAL segments necessary for backup consistency to reach the repository.

Repository backups can use the same format as a standard PostgreSQL cluster, including tablespaces. With compression disabled and hard links enabled, you can take a snapshot of a repository backup. You can then start a PostgreSQL cluster directly on the snapshot. This method helps with terabyte-scale databases, where a conventional restore takes a long time.

All operations use file and directory fsync to make changes durable.

Page Checksums

If page checksums are enabled, pgBackRest validates them for every file copied during a backup. A full backup validates all page checksums. Differential and incremental backups validate checksums in changed files.

Validation failures do not stop the backup. Console and file logs identify the pages that failed validation.

This feature detects page-level corruption before backups with valid copies of the data expire.

Backup Resume

You can resume an interrupted backup from its last position. pgBackRest compares checksums of previously copied files with the manifest to check their integrity. This operation can run entirely on the repository host, which reduces load on the PostgreSQL host. Checksum calculation also takes less time than compression and retransmission.

Streaming Compression & Checksums

pgBackRest calculates checksums and compresses data as it copies files to the repository. This applies to local and remote repositories.

For a repository on a separate host, pgBackRest compresses files on the PostgreSQL host. It transfers the compressed files and stores them on the repository host. When file compression is disabled, pgBackRest uses a lower compression level for transfers. This reduces bandwidth use with minimal CPU cost.

Delta Restore

The manifest contains a checksum for every backup file. A restore can use these checksums to substantially reduce processing time. A delta restore first removes files that are absent from the backup. It then calculates checksums for the remaining files. Files that match the backup stay in place; pgBackRest restores the other files as usual. Parallel processing can substantially reduce restore time.

Parallel, Asynchronous WAL Push & Get

Separate commands push WAL to the archive and get WAL from the archive. Both commands support parallel processing and asynchronous operation to reduce response time for PostgreSQL.

WAL push detects repeated WAL segments. It removes duplicates when the segments are identical and reports an error when they differ. Asynchronous WAL push transfers work to another process, which compresses segments in parallel for maximum throughput. This feature can be critical for databases with very high write volumes.

Asynchronous WAL get keeps a local queue of decompressed WAL segments ready for replay. This queue reduces the time to supply WAL to PostgreSQL and increases replay speed. Connections and storage with high latency, such as S3, benefit most.

The push and get commands compare PostgreSQL versions and system identifiers to check that the database and repository match. This check almost eliminates incorrect WAL archive locations.

pgBackRest fully supports tablespaces. During a restore, you can map tablespaces to any location. You can also map all tablespaces to one location with one command. This is useful for development restores.

pgBackRest supports links for any file or directory in the PostgreSQL cluster. During a restore, you can restore all links to their original locations or map some or all links to new locations. You can also restore some or all links as regular files or directories inside the cluster directory.

S3, Azure, and GCS Compatible Object Store Support

pgBackRest repositories support S3, Azure, and GCS compatible object stores. These stores provide almost unlimited capacity and retention.

Encryption

pgBackRest can encrypt the repository to secure backups wherever they are stored.

Ransomware & Malware Protection

On versioned object storage, pgBackRest can read the repository at a specified point in time. Backups can be deleted or corrupted by an accident, malware, or ransomware. Set a target time before the damage to recover the data.

S3, Azure, and GCS compatible object stores support versioning. S3 object locking and GCS or Azure soft delete can provide more protection against tampering.

Compatibility with ten versions of PostgreSQL

pgBackRest supports ten PostgreSQL versions: the five supported versions and the last five EOL versions. This gives users time to upgrade to a supported version.


Getting Started

Use these documents to configure and operate pgBackRest:


Contributions

pgBackRest welcomes contributions. See the Contributing Guidelines to contribute features, improvements, or issues.


Support

pgBackRest is completely free and open source under the MIT license. You may use it for personal or commercial purposes without any restrictions whatsoever. Bug reports are taken very seriously and will be addressed as quickly as possible. Please report bugs here.

A disaster recovery policy needs suitable replication and backup strategies. The design can be complex. You might need help with the architecture and ongoing support to keep your enterprise running.

Our sponsors offer products and services with pgBackRest support. They can help you meet your disaster recovery requirements.

1 - News

Official pgBackRest project news, release announcements, and maintenance updates.

Source: https://pgbackrest.org/news.html


pgBackRest 2.59.2 Released

September 27, 2026

The pgBackRest community released pgBackRest 2.59.2. This backup and restore solution supports PostgreSQL databases and workloads of all sizes.

pgBackRest provides these backup and recovery features: parallel backup and restore; full, differential, incremental, and block incremental backups; and multiple repositories. It also supports delta restore, parallel asynchronous archiving, malware/ransomware protection, per-file checksums, and validation of enabled page checksums during backup. Other features include multiple compression types, encryption, partial/failed backup resume, standby backups, tablespaces, and links. Storage options include S3, Azure, GCS, and SFTP. pgBackRest also supports backup expiration, local or remote operation through SSH or TLS, and flexible configuration.

Install pgBackRest from the PostgreSQL Yum Repository or PostgreSQL APT Repository. Many other distributions also provide packages. Download source code from releases.

New Features and Bug Fixes

  • PostgreSQL 19beta4 support (David Steele)
  • Fix empty block map when file is truncated to zero during backup (David Steele)
  • Disable read retry when filters are passed to the driver (David Steele)
  • Fix pagination of S3 version listing (David Steele)
  • Set the Azure version header for SAS authentication (David Steele)
  • Fix async archive-push stalling on a zero-size backup history file (Andrew Kroh)
  • Fix annotate command on a remote encrypted repository (Douglas J Hunley)

See the 2.59.2 Release Notes for additional fixes and improvements.

Important Notes

  • PostgreSQL 19beta4 changed pg_control and WAL formats. Clusters and WAL from earlier 19 beta versions are no longer supported. Recreate those clusters with 19beta4.

Sponsorship

The following sponsors made this release possible: AWS, Supabase, pgEdge, Tiger Data, Percona, Eon, Xata, Dalibo, and Data Egret.


pgBackRest 2.59.1 Released

August 17, 2026

The pgBackRest community released pgBackRest 2.59.1. This backup and restore solution supports PostgreSQL databases and workloads of all sizes.

pgBackRest provides these backup and recovery features: parallel backup and restore; full, differential, incremental, and block incremental backups; and multiple repositories. It also supports delta restore, parallel asynchronous archiving, malware/ransomware protection, per-file checksums, and validation of enabled page checksums during backup. Other features include multiple compression types, encryption, partial/failed backup resume, standby backups, tablespaces, and links. Storage options include S3, Azure, GCS, and SFTP. pgBackRest also supports backup expiration, local or remote operation through SSH or TLS, and flexible configuration.

Install pgBackRest from the PostgreSQL Yum Repository or PostgreSQL APT Repository. Many other distributions also provide packages. Download source code from releases.

New Features and Bug Fixes

  • PostgreSQL 19beta3 support (Lardière Sébastien)
  • Fix hang when the chunk buffer is smaller than the input buffer (David Steele)
  • Compare a new backup label only against its own full backup set (David Steele)
  • Fix source archives generated by GitHub missing files required to build (David Steele)

See the 2.59.1 Release Notes for additional fixes and improvements.

Important Notes

  • PostgreSQL 19beta3 changed the WAL format. WAL archived from earlier PostgreSQL 19 beta versions is no longer readable. Recreate those clusters with 19beta3.

Sponsorship

The following sponsors made this release possible: AWS, Supabase, pgEdge, Tiger Data, Percona, Eon, Xata, Dalibo, and Data Egret.


New Distribution Tarball

July 20, 2026

Starting with pgBackRest 2.59.0, each release includes a distribution tarball for simpler source builds. It contains generated source and prebuilt documentation. Unlike a Git checkout, it does not need code-generation or documentation tools to build and install pgBackRest.

The tarball contains source, pregenerated code, a command reference man page, HTML documentation, and a smoke test. Build it with meson and ninja and the usual pgBackRest libraries.

Each release includes pgbackrest-{version}.tar.gz and a matching .sha256sum checksum. Download them from GitHub releases. Follow the tarball README.md for build and test instructions.

Packagers should use the distribution tarball. This avoids the additional code-generation and documentation tools that future releases will require.


pgBackRest 2.59.0 Released

July 20, 2026

The pgBackRest community released pgBackRest 2.59.0. This backup and restore solution supports PostgreSQL databases and workloads of all sizes.

pgBackRest provides these backup and recovery features: parallel backup and restore; full, differential, incremental, and block incremental backups; and multiple repositories. It also supports delta restore, parallel asynchronous archiving, malware/ransomware protection, per-file checksums, and validation of enabled page checksums during backup. Other features include multiple compression types, encryption, partial/failed backup resume, standby backups, tablespaces, and links. Storage options include S3, Azure, GCS, and SFTP. pgBackRest also supports backup expiration, local or remote operation through SSH or TLS, and flexible configuration.

Install pgBackRest from the PostgreSQL Yum Repository or PostgreSQL APT Repository. Many other distributions also provide packages. Download source code from releases.

Significant New Features and Improvements

  • PostgreSQL 19 support (David Steele)
  • Add archive-expire-before option to clean up WAL archive (Stefan Fercot)
  • Add support for S3 Outposts (Shiva Kumar Ambigi)
  • Add S3 process authentication (David Steele)
  • Add user/group caching for faster manifest build (Gunnar Lindholm)
  • Reconnect SFTP storage after the server drops an idle connection (David Steele)
  • Add per-repo backup progress to info command output (Will Morland)
  • Add batch delete for Azure storage (David Steele)
  • Add backup.info checks to verify command (Denis Garsh)
  • Allow the S3 STS endpoint to be configured (Simon Gratton)
  • Add systemd notify integration (Andrew Jackson)
  • Error when running as root unless allow-root is enabled (David Steele)
  • Exit async archive-push on first error (David Steele)

See the 2.59.0 Release Notes for additional features and improvements.

Important Notes

  • By default, only restore can run as root. Use allow-root for other commands, although this is not recommended.
  • Each release includes a distribution tarball with pregenerated documentation, man page, and code to simplify packaging. See New Distribution Tarball.
  • libsystemd is a new optional dependency.

Sponsorship

The following sponsors made this release possible: AWS, Supabase, pgEdge, Tiger Data, Percona, Eon, Xata, Dalibo, and Data Egret.


pgBackRest Will Continue!

May 18, 2026

pgBackRest will continue. During the previous few weeks, several sponsors agreed to fund ongoing development. The project no longer depends on one sponsor. This supports its long-term stability.

We thank each sponsor:

Amazon Web Services provides on-demand cloud resources for individuals, companies, and governments. It offers computing, storage, databases, machine learning, and more than 200 services with usage-based payment. It supports growth and invests in shared communities.

Supabase is a PostgreSQL backend platform. It lets developers build and scale applications without managing infrastructure. It includes a Postgres database, user authentication, real-time subscriptions, file storage, edge functions, and serverless functions. An active open-source community supports it.

pgEdge is an enterprise open-source Postgres platform for AI and high availability. It includes agentic AI tools, a DBA workbench, monitoring, incident response, flexible deployment, and maintenance without downtime. Deployments range from one node to active-active multi-master clusters in cloud, on-premises, or air-gapped environments.

Tiger Data created TimescaleDB, an open-source PostgreSQL time-series database. It also operates Tiger Cloud for managed time-series, analytics, and AI workloads. Self-managed and cloud options let organizations capture, store, and analyze time-series data at scale, from edge locations to centralized cloud deployments.

Percona provides open-source database software, support, and services to help organizations control their data infrastructure. It supports secure, efficient operation of MySQL, PostgreSQL, MongoDB, Valkey, and Redis. Services include freely available software, 24/7 expert support, and practical database assistance.

Eon.io provides cloud infrastructure for backup, recovery, and data management. It helps teams store and access backups efficiently and use the data for analytics and AI. It offers fast, granular recovery and substantially lower storage costs for Postgres and data-intensive workloads across clouds. Recovery includes accidental data loss and AI agent regressions.

These organizations use pgBackRest for disaster recovery in their products and customer services. Their investment reflects its role in the PostgreSQL ecosystem. Their combined support sustains the project over the long term.

I look forward to resuming work on features and optimizations for upcoming releases. Thank you to our sponsors for funding this work. Thank you to the community for its patience and support during this transition.


Maintenance Update

May 4, 2026

After I announced that I would stop maintaining pgBackRest, I received many messages. Many expressed thanks and good wishes for my work over the years. It took time to read them.

Many users want pgBackRest to continue with me as primary maintainer, especially users who support others using pgBackRest. I also want this. However, after months of fundraising, I had concluded that it was not possible.

The situation has changed. I now expect to secure enough funding to continue the project. Several sponsors will fund pgBackRest, so one acquisition will no longer determine whether I can continue. We should also be able to add another maintainer to share the workload and provide continuity.

I understand the shock and uncertainty. Please give us time. The current pgBackRest version works, with no outstanding critical bugs or security issues. There is no immediate need to fork the project.

I expect to make a more definite announcement by the end of the week. Until then, we are actively working to resume pgBackRest development.


pgBackRest Is No Longer Being Maintained

April 27, 2026

pgBackRest is no longer maintained. If you fork it, choose a new project name.

After careful thought, I have decided to stop working on pgBackRest. I have worked on this project for thirteen years, with corporate sponsorship for much of that time. I also spent many nights and weekends developing it with numerous contributors. This reflects the substantial personal commitment that an open-source project can require.

Since the sale of Crunchy Data, I have maintained pgBackRest while seeking a position that would support this work. I have not found one. Sponsorship efforts have also raised much less than the project needs to remain viable.

I need to earn a living, and few roles involve pgBackRest. I can now consider other opportunities, but they will leave no time for this project. Maintenance, bug fixes, PR reviews, and issue responses already require substantial time. New features, the work I most enjoy, need additional time. I have therefore decided to stop completely instead of working irregularly or inadequately.

Someone might eventually fork pgBackRest. That would be a new project with new maintainers. They would need to earn trust, as we did.

Thank you to all pgBackRest contributors over the years. I enjoyed working with you.

2 - User Guide (Debian/Ubuntu)

Step-by-step pgBackRest setup and usage guide for Debian and Ubuntu systems.

Source: pgBackRest 2.59.2 user guide.


Introduction

Follow this guide in order the first time. Each section depends on earlier sections. For example, Restore requires the configuration from Quick Start. After pgBackRest is running, you can use sections independently.

These examples use Debian/Ubuntu and PostgreSQL 17. You can adapt them to other Unix distributions and PostgreSQL versions. Only commands to create, start, stop, and drop clusters depend on the OS. pgBackRest commands are the same across Unix systems, although the executable location can differ. PostgreSQL versions can differ in paths, file names, and settings; some examples show these differences.

Configuration information and documentation for PostgreSQL can be found in the PostgreSQL Manual.

The documentation build runs each command on a virtual machine from the XML source. This verifies that commands work in the specified order. Relevant output appears below each command. Other output is omitted to keep the instructions clear.

Run commands as an unprivileged user with sudo access to root and postgres. Alternatively, run each command directly as its specified user and remove sudo.


Concepts

The following definitions apply to pgBackRest, PostgreSQL, and this guide.

Backup

A backup is a consistent copy of a database cluster. Restore it to recover from hardware failure, perform Point-In-Time Recovery, or create a standby.

Full Backup: Copy all database cluster contents. The first cluster backup is always full. pgBackRest can restore it directly without files from another backup to achieve consistency.

Differential Backup: Copy files changed since the last full backup. Restore combines those files with unchanged files from that full backup. This uses less disk space than a full backup. Both the differential and its full backup must be valid for a restore.

Incremental Backup: Copy files changed since the last backup, whether full, differential, or incremental. Incremental backups are usually much smaller than full or differential backups. A restore requires valid versions of every backup in its dependency chain. This includes all incrementals back to the preceding differential, that differential, and its full backup. If no differential exists, it includes all incrementals back to the full backup and that full backup itself.

Restore

A restore copies backup files to a system where PostgreSQL can start them as a live cluster. It requires backup files and one or more WAL segments.

Write Ahead Log (WAL)

PostgreSQL uses WAL to prevent loss of committed changes. It writes transactions sequentially to WAL and considers them committed when those writes reach disk. A background process then writes the changes to the main database files, also called the heap. After a crash, WAL replay restores database consistency.

WAL is conceptually infinite but consists of individual 16MB segment files. A segment name has the form 0000000100000A1E000000FE. The first 8 hexadecimal digits identify the timeline. The next 16 identify the logical sequence number (LSN).

Encryption

Encryption converts data into a form that requires the correct password, also called a passphrase, to read.

pgBackRest encrypts the repository with a user-supplied password to prevent unauthorized access to its stored data.


Upgrading pgBackRest

Upgrading pgBackRest from v2.x to v2.y

To upgrade from v2.x to v2.y, most installations only need the new binaries. The repository format is unchanged. You can also downgrade unless you have used features that the older version does not support.

IMPORTANT:

Local and remote pgBackRest versions must match exactly. Upgrade them together. If versions differ, WAL archiving and backups fail until they match. The error is: [ProtocolError] expected value '2.x' for greeting key 'version' but got '2.y'.


Build

Prefer package installation to a source build. See Installation for package information.

Build from source on a separate build host. Production hosts generally should not have the required build tools. pgBackRest is one executable, which you can copy to other hosts after the build.

build ⇒ Download version 2.59.2 of pgBackRest to /build path

mkdir -p /build
curl -fsSL \
       https://github.com/pgbackrest/pgbackrest/releases/download/release%2F2.59.2/pgbackrest-2.59.2.tar.gz | \
       tar zx -C /build

build ⇒ Install build dependencies

sudo apt-get install python3-distutils meson gcc libpq-dev libssl-dev libxml2-dev \
       pkg-config liblz4-dev libzstd-dev libbz2-dev libz-dev libssh2-1-dev libsystemd-dev

build ⇒ Configure and compile pgBackRest

meson setup /build/pgbackrest /build/pgbackrest-2.59.2
ninja -C /build/pgbackrest

build ⇒ Optionally run smoke tests to verify pgBackRest was built correctly

meson test -C /build/pgbackrest --suite smoke
ninja: Entering directory `/build/pgbackrest'
ninja: no work to do.
1/1 smoke OK               10.91s
       [filtered 7 lines of output]

Installation

Create a host named pg-primary for the demo cluster and pgBackRest examples.

Prefer package installation to a source build. Packages usually perform the remaining steps in this section. If a package omits a directory or sets incorrect permissions, create the directory or correct its permissions manually.

Debian/Ubuntu packages for pgBackRest are available at apt.postgresql.org.

If your distribution or version has no package, build from source and follow these manual installation steps.

pg-primary ⇒ Install dependencies

sudo apt-get install postgresql-client libxml2 libssh2-1

pg-primary ⇒ Copy pgBackRest binary from build host

sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest

pgBackRest requires log and configuration directories and a configuration file.

pg-primary ⇒ Create pgBackRest configuration file and directories

sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf

Check the installation. Running pgBackRest on the command line reports an error if a dependency is missing.

pg-primary ⇒ Make sure the installation worked

sudo -u postgres pgbackrest
pgBackRest 2.59.2 - General help

Usage:
    pgbackrest [options] [command]

Commands:
    annotate        add or modify backup annotation
    archive-get     get a WAL segment from the archive
    archive-push    push a WAL segment to the archive
    backup          backup a database cluster
    check           check the configuration
    expire          expire backups that exceed retention
    help            get help
    info            retrieve information about backups
    repo-get        get a file from a repository
    repo-ls         list files in a repository
    restore         restore a database cluster
    server          pgBackRest server
    server-ping     ping pgBackRest server
    stanza-create   create the required stanza data
    stanza-delete   delete a stanza
    stanza-upgrade  upgrade a stanza
    start           allow pgBackRest processes to run
    stop            stop pgBackRest processes from running
    verify          verify contents of a repository
    version         get version

Use 'pgbackrest help [command]' for more information.

Quick Start

Quick Start covers basic pgBackRest and PostgreSQL configuration. It introduces backup, restore, and info.

Setup Demo Cluster

The demo cluster is optional but strongly recommended, especially for new users. Examples use this cluster on the default port, 5432. Start it in a later section after configuration is complete.

pg-primary ⇒ Create the demo cluster

sudo -u postgres /usr/lib/postgresql/17/bin/initdb \
       -D /var/lib/postgresql/17/demo -k -A peer

sudo pg_createcluster 17 demo
Configuring already existing cluster (configuration: /etc/postgresql/17/demo, data: /var/lib/postgresql/17/demo, owner: 102:103)
Ver Cluster Port Status Owner    Data directory              Log file
17  demo    5432 down   postgres /var/lib/postgresql/17/demo /var/log/postgresql/postgresql-17-demo.log

Configure Cluster Stanza

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

Use demo as the stanza name because it describes the cluster purpose.

pgBackRest needs the PostgreSQL base data directory. PostgreSQL can report it, but is unavailable during recovery. Set pg-path to exactly the data_directory value reported by PostgreSQL. Each backup compares these paths and fails if they differ.

Debian/Ubuntu stores clusters in /var/lib/postgresql/[version]/[cluster] by default. Use this location to identify the data directory.

When you create /etc/pgbackrest/pgbackrest.conf, grant read access to the database owner, usually postgres.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure the PostgreSQL cluster data directory

[demo]
pg1-path=/var/lib/postgresql/17/demo

pgBackRest configuration files use a Windows INI-like format. Bracketed section names contain key/value pairs. Lines starting with # are comments; comments after a value on the same line are unsupported. Quoting is unsupported. pgBackRest trims whitespace from keys and values. Repeated sections are merged.

Configuration loading depends on these options:

  • Default config and config-include-path: load the default file if present. Append *.conf files from the default include path if present.
  • Explicit config: load only the specified file, which must exist.
  • Explicit config-include-path: load its *.conf files; the path must exist. Also load the default configuration file if present. Add --no-config to load only include-path files.
  • Explicit config and config-include-path: load the specified file and append *.conf files from the specified include path. The files must exist.
  • Explicit config-path: override the base path for the default configuration file and include path. Explicit config or config-include-path settings take precedence.

pgBackRest combines the files as one file, but each file must be valid independently. Each file must declare sections for its key/value pairs. File order does not determine precedence; sections do. The order from highest to lowest precedence is:

  • [stanza:command]
  • [stanza]
  • [global:command]
  • [global]

NOTE:

--config, --config-include-path and --config-path are command-line only options.

Environment variables can also configure pgBackRest, as shown below. They apply to commands such as backup, restore, and archive-push.

pg-primary ⇒ Configure log-path using the environment

sudo -u postgres bash -c ' \
       export PGBACKREST_LOG_PATH=/path/set/by/env && \
       pgbackrest --log-level-console=error help backup log-path'
pgBackRest 2.59.2 - 'backup' command - 'log-path' option help

Path where log files are stored.

The log path provides a location for pgBackRest to store log files. Note that
if log-level-file=off then no log path is required.
current: /path/set/by/env

default: /var/log/pgbackrest

Create the Repository

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

This example stores the repository on the PostgreSQL host. This is the simplest configuration. It is useful when conventional backup software also backs up that host.

pg-primary ⇒ Create the pgBackRest repository

sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown postgres:postgres /var/lib/pgbackrest

Configure the repository path so pgBackRest can find it.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure the pgBackRest repository path

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-path=/var/lib/pgbackrest

You can configure multiple repositories. See Multiple Repositories.

Configure Archiving

Enable WAL archiving before backing up a running PostgreSQL cluster. PostgreSQL uses %p to specify the WAL segment location. A backup creates at least one WAL segment, even without explicit cluster writes.

pg-primary:/etc/postgresql/17/demo/postgresql.conf ⇒ Configure archive settings

archive_command = 'pgbackrest --stanza=demo archive-push %p'
archive_mode = on

After these changes, restart the PostgreSQL cluster before taking a backup.

pg-primary ⇒ Restart the demo cluster

sudo pg_ctlcluster 17 demo restart

Keep hot_standby enabled, which is the default, on every cluster. Any cluster might later become a standby, including a former primary after failover. A standby requires this setting to accept read-only connections.

If a WAL segment needs more than the default 60 seconds to reach the repository, increase pgBackRest archive-timeout. This differs from PostgreSQL archive_timeout, which forces a WAL segment switch during long inactive periods. See PostgreSQL Write Ahead Log for archive_timeout details.

Set command-specific options for archive-push. For example, a lower compression level can speed archiving without changing backup compression.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Config archive-push to use a lower compression level

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-path=/var/lib/pgbackrest
[global:archive-push]
compress-level=3

Use command-specific configuration for any command. You can also limit it to one stanza, such as demo:archive-push.

Configure Retention

pgBackRest expires backups based on retention options.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure retention to 2 full backups

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
[global:archive-push]
compress-level=3

See Retention for more information.

Configure Repository Encryption

Set a repository cipher type and key to demonstrate encryption. Encryption always occurs on the client, even when storage such as S3 supports encryption.

Use a long, random passphrase for the cipher key. Generate one with openssl rand -base64 48.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pgBackRest repository encryption

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
[global:archive-push]
compress-level=3

NOTE:

The example puts encryption settings in [global] so info can read all stanzas. Without stanza, info reads encryption settings only from [global]. For stanza-specific encryption, supply stanza to read the encrypted stanza.

After configuring the repository and creating and checking the stanza, you cannot change its encryption settings.

Create the Stanza

Run stanza-create to initialize the stanza. Then run check to verify archive and backup configuration.

pg-primary ⇒ Create the stanza and check the configuration

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00   INFO: stanza-create command begin 2.59.2: --exec-id=418-ea48493a --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo
P00   INFO: stanza-create for stanza 'demo' on repo1

P00   INFO: stanza-create command end: completed successfully

Check the Configuration

The check command validates pgBackRest and archive_command configuration for the specified stanza. It checks backup and archive settings for all repositories and databases configured on the current host. It detects configuration errors, especially archive errors that leave backups incomplete because required WAL segments never reached the archive. Run it on the PostgreSQL or repository host. You can also run it on a standby, but then it checks only repository configuration. A standby cannot execute pg_switch_xlog()/pg_switch_wal().

The command calls pg_create_restore_point('pgBackRest Archive Check') and pg_switch_xlog()/pg_switch_wal() to force PostgreSQL to archive a WAL segment.

pg-primary ⇒ Check the configuration

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=427-13fc86bf --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo
P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 000000010000000000000001 successfully archived to '/var/lib/pgbackrest/archive/demo/17-1/0000000100000000/000000010000000000000001-d90c1b216d8173f5bcfd18f31ea16e25f9e9d786.gz' on repo1

P00   INFO: check command end: completed successfully

Performance Tuning

Some performance options are disabled by default to preserve repository compatibility. Enable the following options for new repositories. You can also enable them for existing repositories, but older pgBackRest versions might then be unable to read them. Compatibility depends on the feature introduction version shown below.

  • compress-type selects compression for backup and archive-push. The default is gz (Gzip). Prefer zst (Zstandard) for much faster processing with similar compression. Support started in v2.27. See Compress Type.
  • repo-bundle combines small files to save space and speed backup and restore, especially on object stores such as S3. It was introduced in v2.39. See File Bundling.
  • repo-block stores changed parts of files during diff/incr backup, which saves space and speeds backups. It was introduced in v2.46, but use at least v2.52.1. See Block Incremental.

Other performance options need additional configuration, or use safe defaults that are not optimal. These options are available in every v2 release.

  • process-max controls the number of processes. Its default, 1, is rarely suitable. Each command uses it differently; see the command documentation.
  • archive-async archives WAL in batches for much higher speed. It is disabled by default because it requires a spool path. See Asynchronous Archiving.
  • backup-standby reduces primary load by backing up from a standby. It is disabled by default because it needs extra configuration and at least one standby. See Backup from a Standby.

Perform a Backup

By default, backups wait for the next regular checkpoint. PostgreSQL checkpoint_timeout and checkpoint_segments settings can make this a long wait. Usually, set start-fast=y to force a checkpoint and start immediately. For a daily backup, one extra checkpoint should have little performance impact. On very busy clusters, use --start-fast on the command line only when needed.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure backup fast start

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

Run pgBackRest backup to back up the PostgreSQL cluster.

pg-primary ⇒ Backup the demo cluster

sudo -u postgres pgbackrest --stanza=demo \
       --log-level-console=info backup
P00   INFO: backup command begin 2.59.2: --exec-id=454-23b0197b --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --start-fast

P00   WARN: no prior backup exists, incr backup has been changed to full

P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 000000010000000000000002, lsn = 0/2000028
       [filtered 3 lines of output]
P00   INFO: check archive for segment(s) 000000010000000000000002:000000010000000000000003
P00   INFO: new backup label = 20260927-101911F

P00   INFO: full backup size = 22MB, file total = 963

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=454-23b0197b --log-level-console=info --no-log-timestamp --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo

By default, pgBackRest attempts an incremental backup. An incremental requires a full backup. Because none existed, pgBackRest created a full backup.

Use type to select a full or differential backup.

pg-primary ⇒ Differential backup of the demo cluster

sudo -u postgres pgbackrest --stanza=demo --type=diff \
       --log-level-console=info backup
       [filtered 7 lines of output]
P00   INFO: check archive for segment(s) 000000010000000000000004:000000010000000000000005
P00   INFO: new backup label = 20260927-101911F_20260927-101914D

P00   INFO: diff backup size = 8.3KB, file total = 963

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=480-6911e174 --log-level-console=info --no-log-timestamp --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo

No warning appeared because a full backup already existed. Incrementals can depend on a full or differential backup. Differentials must depend on a full backup. To create a full backup, run backup with --type=full.

During an online backup, pgBackRest waits for the archive to receive all WAL segments necessary for consistency. The archive-timeout default is 60 seconds. Increase it if an individual segment takes longer to archive.

Schedule a Backup

Backups can be scheduled with utilities such as cron.

The example schedules full backups at 6:30 AM each Sunday. It schedules differential backups at 6:30 AM Monday through Saturday. If installed midweek, the first differential job creates a full backup. The next day, it creates a differential.

#m h   dom mon dow   command
30 06  *   *   0     pgbackrest --type=full --stanza=demo backup
30 06  *   *   1-6   pgbackrest --type=diff --stanza=demo backup

After scheduling backups, configure regular expiration. See Retention.

Backup Information

Use the info command to get information about backups.

pg-primary ⇒ Get info for the demo cluster

sudo -u postgres pgbackrest info
stanza: demo
    status: ok
    cipher: aes-256-cbc

    db (current)
        wal archive min/max (17): 000000010000000000000001/000000010000000000000005
        full backup: 20260927-101911F
            timestamp start/stop: 2026-09-27 10:19:11+00 / 2026-09-27 10:19:14+00
            wal start/stop: 000000010000000000000002 / 000000010000000000000003
            database size: 22MB, database backup size: 22MB
            repo1: backup set size: 2.9MB, backup size: 2.9MB
        diff backup: 20260927-101911F_20260927-101914D
            timestamp start/stop: 2026-09-27 10:19:14+00 / 2026-09-27 10:19:16+00
            wal start/stop: 000000010000000000000004 / 000000010000000000000005
            database size: 22MB, database backup size: 8.3KB
            repo1: backup set size: 2.9MB, backup size: 464B
            backup reference total: 1 full

The info command reports on one stanza or all stanzas. By default, text output summarizes backups for the requested stanzas. The text format can change in any release.

For machine-readable output, use --output=json. JSON includes much more information than text output. Its format stays stable unless a bug requires a change.

Use --detail-level=progress to show only progress and reduce execution time. This skips all checks except stanza availability.

Each stanza has a separate section. Use --stanza to show only one. The status field indicates stanza health: ok means pgBackRest operates normally. With multiple repositories, mixed means at least one repository has an unhealthy stanza; output then gives the status per repository. An unknown repository error uses the code other and includes full error details.

The wal archive min/max field shows the minimum and maximum archived WAL. With multiple repositories, it covers all repositories unless you set --repo. Archive retention policies or other causes can leave gaps in this range.

The backup/expire running and/or restore running messages appear beside status when those commands run on the host. Text output also shows progress per repository. JSON output includes a repo array.

Backups appear from oldest to newest. The oldest is always a full backup, with an F at the end of its label. The newest can be full, differential (label ends with D), or incremental (label ends with I).

The timestamp start/stop field shows when the backup ran. Use timestamp stop to select a backup for Point-In-Time Recovery. See Point-In-Time Recovery.

The wal start/stop field shows the WAL range necessary for database consistency after a restore. The backup command checks that the archive contains this range before it completes.

The database size field shows the full, uncompressed database size. The database backup size field shows the database data actually backed up. These values match for full backups.

The repo field identifies the repository that contains the backup. The backup set size includes files in this backup and referenced backups needed for a restore. The backup size includes only files in this backup. These sizes match for full backups. When pgBackRest compression is enabled, repository sizes reflect compressed files.

The backup reference total summarizes other backups needed to restore this backup. Use --set for the complete reference list.

Restore a Backup

Backups protect against failures, including hardware failure and data corruption. For this example, simulate corruption by removing an essential cluster file.

pg-primary ⇒ Stop the demo cluster and delete the pg_control file

sudo pg_ctlcluster 17 demo stop
sudo -u postgres rm /var/lib/postgresql/17/demo/global/pg_control

Starting the cluster without this file produces an error.

pg-primary ⇒ Attempt to start the corrupted demo cluster

sudo pg_ctlcluster 17 demo start
Error: /usr/lib/postgresql/17/bin/pg_ctl /usr/lib/postgresql/17/bin/pg_ctl start -D /var/lib/postgresql/17/demo -l /var/log/postgresql/postgresql-17-demo.log -s -o  -c config_file="/etc/postgresql/17/demo/postgresql.conf"  exited with status 1:

postgres: could not find the database system

Expected to find it in the directory "/var/lib/postgresql/17/demo",
but could not open file "/var/lib/postgresql/17/demo/global/pg_control": No such file or directory
Examine the log output.

Run pgBackRest restore to restore the PostgreSQL cluster. First stop the cluster, which is already stopped in this example. Remove all files from its data directory.

pg-primary ⇒ Remove old files from demo cluster

sudo -u postgres find /var/lib/postgresql/17/demo -mindepth 1 -delete

pg-primary ⇒ Restore the demo cluster and start PostgreSQL

sudo -u postgres pgbackrest --stanza=demo restore
sudo pg_ctlcluster 17 demo start

The cluster started because the restore replaced the missing pg_control file.

See Restore for more information about restore.


Monitoring

Monitor production systems. You can integrate pgBackRest with many monitoring tools.

pgBackRest JSON output includes all backups for each stanza and WAL archive information.

In PostgreSQL

Use PostgreSQL COPY to load pgBackRest information into a table. This example puts that logic in a function for real-time queries.

pg-primary ⇒ Load pgBackRest info function for PostgreSQL

sudo -u postgres cat \
       /var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql
-- An example of monitoring pgBackRest from within PostgreSQL
--
-- Use copy to export data from the pgBackRest info command into the jsonb
-- type so it can be queried directly by PostgreSQL.

-- Create monitor schema
create schema monitor;

-- Get pgBackRest info in JSON format
create function monitor.pgbackrest_info()
    returns jsonb AS $$
declare
    data jsonb;
begin
    -- Create a temp table to hold the JSON data
    create temp table temp_pgbackrest_data (data text);

    -- Copy data into the table directly from the pgBackRest info command
    copy temp_pgbackrest_data (data)
        from program
            'pgbackrest --output=json info' (format text);

    select replace(temp_pgbackrest_data.data, E'\n', '\n')::jsonb
      into data
      from temp_pgbackrest_data;

    drop table temp_pgbackrest_data;

    return data;
end $$ language plpgsql;
sudo -u postgres psql -f \
       /var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql

Use monitor.pgbackrest_info() to find a stanza’s last successful backup time and archived WAL.

pg-primary ⇒ Query last successful backup time and archived WAL

sudo -u postgres cat \
       /var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-query.sql
-- Get last successful backup for each stanza
--
-- Requires the monitor.pgbackrest_info function.
with stanza as
(
    select data->'name' as name,
           data->'backup'->(
               jsonb_array_length(data->'backup') - 1) as last_backup,
           data->'archive'->(
               jsonb_array_length(data->'archive') - 1) as current_archive
      from jsonb_array_elements(monitor.pgbackrest_info()) as data
)
select name,
       to_timestamp(
           (last_backup->'timestamp'->>'stop')::numeric) as last_successful_backup,
       current_archive->>'max' as last_archived_wal
  from stanza;
sudo -u postgres psql -f \
       /var/lib/postgresql/pgbackrest/doc/example/pgsql-pgbackrest-query.sql
  name  | last_successful_backup |    last_archived_wal
--------+------------------------+--------------------------
 "demo" | 2026-09-27 10:19:16+00 | 000000010000000000000005
(1 row)

Using jq

The jq command-line utility extracts data from JSON.

pg-primary ⇒ Install jq utility

sudo apt-get install jq

Use jq to query a stanza’s last successful backup time.

pg-primary ⇒ Query last successful backup time

sudo -u postgres pgbackrest --output=json --stanza=demo info | \
       jq '.[0] | .backup[-1] | .timestamp.stop'
1790504356

You can also query the last archived WAL.

pg-primary ⇒ Query last archived WAL

sudo -u postgres pgbackrest --output=json --stanza=demo info | \
       jq '.[0] | .archive[-1] | .max'
"000000010000000000000005"

NOTE:

This syntax requires jq v1.5.

NOTE:

jq may round large numbers such as system identifiers. Test your queries carefully.


Backup

With multiple repositories, pgBackRest backs up to the highest priority repository, such as repo1. Use --repo to select another repository.

pgBackRest has no built-in scheduler. Use cron or another scheduler to run it.

See Perform a Backup for more details and examples.

File Bundling

File bundles reduce backup time and repository space. Benefits are greatest on object stores, such as S3, and filesystems with large blocks. Object stores have higher per-file creation costs. Very small files can cost as much to store as larger files.

Enable file bundles with repo-bundle.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-bundle

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

A full backup without bundles has more than 1000 files in its backup path. Bundles substantially reduce this count. Zero-length files then have only manifest entries. Without bundles, each zero-length file is stored separately.

pg-primary ⇒ Perform a full backup

sudo -u postgres pgbackrest --stanza=demo --type=full backup

pg-primary ⇒ Check file total

sudo -u postgres find /var/lib/pgbackrest/backup/demo/latest/ -type f | wc -l
5

Tune bundles with repo-bundle-size and repo-bundle-limit. The defaults should suit most cases.

Bundles usually improve efficiency, but make manual file retrieval harder. They might also be unsuitable for deduplicated storage because each full backup arranges files differently. Bundles cannot resume after interruption. Avoid a very high repo-bundle-limit.

Block Incremental

Block incremental backups store only file parts changed since the previous backup. This saves space compared with storing entire files.

Enable block incremental backups with repo-block. They work best when enabled for every backup type. File bundles must also be enabled.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-block

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

Backup Annotations

Attach informative key/value pairs to the backup. Repeat this option to attach multiple annotations.

pg-primary ⇒ Perform a full backup with annotations

sudo -u postgres pgbackrest --stanza=demo --annotation=source="demo backup" \
       --annotation=key=value --type=full backup

When --set specifies a backup, the info command includes its annotations in text output. JSON output always includes annotations.

pg-primary ⇒ Get info for the demo cluster

sudo -u postgres pgbackrest --stanza=demo --set=20260927-101930F info
stanza: demo
    status: ok
    cipher: aes-256-cbc

    db (current)
        wal archive min/max (17): 000000020000000000000007/000000020000000000000009

        full backup: 20260927-101930F
            timestamp start/stop: 2026-09-27 10:19:30+00 / 2026-09-27 10:19:31+00
            wal start/stop: 000000020000000000000008 / 000000020000000000000009
            lsn start/stop: 0/8000028 / 0/9000050
            database size: 22MB, database backup size: 22MB
            repo1: backup size: 2.9MB
            database list: postgres (5)

            annotation(s)

                key: value
                source: demo backup

Use annotate to add, change, or remove annotations after the backup command creates a backup.

pg-primary ⇒ Change backup annotations

sudo -u postgres pgbackrest --stanza=demo --set=20260927-101930F \
       --annotation=key= --annotation=new_key=new_value annotate
sudo -u postgres pgbackrest --stanza=demo --set=20260927-101930F info
stanza: demo
    status: ok
    cipher: aes-256-cbc

    db (current)
        wal archive min/max (17): 000000020000000000000007/000000020000000000000009

        full backup: 20260927-101930F
            timestamp start/stop: 2026-09-27 10:19:30+00 / 2026-09-27 10:19:31+00
            wal start/stop: 000000020000000000000008 / 000000020000000000000009
            lsn start/stop: 0/8000028 / 0/9000050
            database size: 22MB, database backup size: 22MB
            repo1: backup size: 2.9MB
            database list: postgres (5)

            annotation(s)

                new_key: new_value
                source: demo backup

Retention

Retain as many backups as practical to extend the Point-in-Time Recovery window. Account for limits such as disk space. Retention options remove backups when they are no longer needed.

pgBackRest rotates full backups according to a count or time period. Count-based retention keeps a specified number, regardless of creation times. Differential retention uses a count, but a differential always expires with its parent full backup. Incremental backups have no independent expiration policy. They expire with their parent full or differential backup. See Full Backup Retention and Differential Backup Retention for examples.

By default, pgBackRest keeps archived WAL for unexpired backups. You can change this per repository with retention-archive options, but this is not recommended. See Archive Retention.

The expire command runs automatically after each successful backup. You can also run it manually. A manual run applies each configured repository’s retention settings; --repo limits it to one repository. Use --set to expire a specific backup set. Without --repo, pgBackRest searches all repositories and expires sets that match. Every expire run also checks and applies archive retention.

Full Backup Retention

repo1-retention-full-type determines whether repo1-retention-full means a backup count or days of retention. New backups must complete before expiration. With repo1-retention-full-type=count and repo1-retention-full=2, three full backups exist before the oldest expires. With repo1-retention-full-type=time and repo1-retention-full=20, at least one full backup must be 20 days old before expiration.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-retention-full

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

repo1-retention-full=2, but only one full backup exists. The next full backup will not expire any full backups.

pg-primary ⇒ Perform a full backup

sudo -u postgres pgbackrest --stanza=demo --type=full \
       --log-level-console=detail backup
       [filtered 975 lines of output]
P00   INFO: repo1: remove expired backup 20260927-101928F
P00 DETAIL: repo1: 17-1 archive retention on backup 20260927-101930F, start = 000000020000000000000008

P00   INFO: repo1: 17-1 remove archive, start = 000000020000000000000007, stop = 000000020000000000000007

P00   INFO: expire command end: completed successfully

Archive data does expire because WAL segments exist from before the oldest backup. These cannot recover that backup. Recovery uses WAL generated after a backup.

pg-primary ⇒ Perform a full backup

sudo -u postgres pgbackrest --stanza=demo --type=full \
       --log-level-console=info backup
       [filtered 11 lines of output]
P00   INFO: repo1: expire full backup 20260927-101930F
P00   INFO: repo1: remove expired backup 20260927-101930F
P00   INFO: repo1: 17-1 remove archive, start = 000000020000000000000008, stop = 000000020000000000000009

P00   INFO: expire command end: completed successfully

Full backup 20260927-101911F expires. Archive retention now follows 20260927-101932F, the oldest remaining full backup.

Differential Backup Retention

Set repo1-retention-diff to the required differential backup count. Differentials depend only on the previous full backup. Keep a changing set covering the last day or longer for fast recent restores with less total space.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-retention-diff

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=1
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

With repo1-retention-diff=1, two differentials must complete before one expires. Add an incremental to demonstrate that it expires with its parent differential.

pg-primary ⇒ Perform differential and incremental backups

sudo -u postgres pgbackrest --stanza=demo --type=diff backup
sudo -u postgres pgbackrest --stanza=demo --type=incr backup

The next differential backup expires the previous differential and its incremental. One differential remains.

pg-primary ⇒ Perform a differential backup

sudo -u postgres pgbackrest --stanza=demo --type=diff \
       --log-level-console=info backup
       [filtered 10 lines of output]
P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=957-5a78b9e0 --log-level-console=info --no-log-timestamp --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-diff=1 --repo1-retention-full=2 --stanza=demo
P00   INFO: repo1: expire diff backup set 20260927-101935F_20260927-101937D, 20260927-101935F_20260927-101938I
P00   INFO: repo1: remove expired backup 20260927-101935F_20260927-101938I
P00   INFO: repo1: remove expired backup 20260927-101935F_20260927-101937D
P00   INFO: expire command end: completed successfully

Archive Retention

By default, archive expiration follows full backup expiration through repo1-retention-full. You can expire archives more aggressively to save disk space. For differential archive retention, full backups also count as differentials.

Archive expiration never removes WAL needed for backup consistency. However, PITR needs a continuous WAL stream. Use care when expiring archives beyond normal backup expiration. To inspect proposed removals, run expire with command-line dry-run.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-retention-diff

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

pg-primary ⇒ Perform differential backup

sudo -u postgres pgbackrest --stanza=demo --type=diff \
       --log-level-console=info backup
       [filtered 6 lines of output]
P00   INFO: backup stop archive = 000000020000000000000017, lsn = 0/17000050
P00   INFO: check archive for segment(s) 000000020000000000000016:000000020000000000000017
P00   INFO: new backup label = 20260927-101935F_20260927-101941D

P00   INFO: diff backup size = 8.3KB, file total = 963
P00   INFO: backup command end: completed successfully
       [filtered 2 lines of output]

pg-primary ⇒ Expire archive

sudo -u postgres pgbackrest --stanza=demo --log-level-console=detail \
       --repo1-retention-archive-type=diff --repo1-retention-archive=1 expire
P00   INFO: expire command begin 2.59.2: --exec-id=1039-a1b1a5e3 --log-level-console=detail --no-log-timestamp --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-archive=1 --repo1-retention-archive-type=diff --repo1-retention-diff=2 --repo1-retention-full=2 --stanza=demo
P00 DETAIL: repo1: 17-1 archive retention on backup 20260927-101932F, start = 00000002000000000000000A, stop = 00000002000000000000000B
P00 DETAIL: repo1: 17-1 archive retention on backup 20260927-101935F, start = 00000002000000000000000C, stop = 00000002000000000000000D
P00 DETAIL: repo1: 17-1 archive retention on backup 20260927-101935F_20260927-101939D, start = 000000020000000000000012, stop = 000000020000000000000013
P00 DETAIL: repo1: 17-1 archive retention on backup 20260927-101935F_20260927-101941D, start = 000000020000000000000016

P00   INFO: repo1: 17-1 remove archive, start = 00000002000000000000000E, stop = 000000020000000000000011
P00   INFO: repo1: 17-1 remove archive, start = 000000020000000000000014, stop = 000000020000000000000015

P00   INFO: expire command end: completed successfully

WAL for 20260927-101935F_20260927-101939D must remain to make older backups consistent, although those backups can no longer support further PITR. Segments generated after 20260927-101935F_20260927-101939D and before 20260927-101935F_20260927-101941D are removed. Segments after the new backup 20260927-101935F_20260927-101941D remain available for PITR.

Full backups count as differentials for differential archive retention. With these settings, a new full backup retains only its own archive for PITR.


Restore

By default, restore selects the latest backup from the first repository with backups. See Quick Start - Restore a Backup. Repository order comes from pgbackrest.conf; for example, repo1 precedes repo2. Use --repo, such as --repo=1, to select a repository. Use --set to select a backup other than the latest.

For PITR with --type=time or --type=lsn, specify the target time or LSN with --target. Without --set, pgBackRest searches configured repositories in order for a backup containing that time or LSN. If none matches, --type=time uses the latest backup in the first repository with backups. For --type=lsn, it selects no backup. For other types, such as xid, use --set if the target precedes the latest backup. See Point-in-Time Recovery.

Backups exclude replication slots, as PostgreSQL recommends. See Backing Up The Data Directory.

The following sections introduce additional restore command features.

File Ownership

A typical restore runs as a non-root user. All restored files belong to the executing user and group. Existing files with other ownership cause an error if pgBackRest cannot change their ownership. Have a privileged user correct the ownership before retrying.

When restore runs as root, pgBackRest attempts to recreate manifest ownership. The manifest stores user/group names, so matching names must exist locally. If a name is absent, use the PostgreSQL data directory owner or group. If that identity also lacks a name, use root.

Delta Option

Restore a Backup in Quick Start required an empty cluster directory before restore. The delta option identifies files that can remain and files that need replacement. It also removes files absent from the manifest, including divergent changes. pgBackRest calculates a SHA-1 hash for each existing file. A file whose SHA-1 differs from the backup is restored.

Use process-max to speed this operation. PostgreSQL is stopped during restore, so you can use more processes than during an online backup.

pg-primary ⇒ Stop the demo cluster, perform delta restore

sudo pg_ctlcluster 17 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
       --log-level-console=detail restore
       [filtered 2 lines of output]
P00 DETAIL: check '/var/lib/postgresql/17/demo' exists
P00 DETAIL: remove 'global/pg_control' so cluster will not start if restore does not complete

P00   INFO: remove invalid files/links/paths from '/var/lib/postgresql/17/demo'

P00 DETAIL: remove invalid file '/var/lib/postgresql/17/demo/backup_label.old'
P00 DETAIL: remove invalid file '/var/lib/postgresql/17/demo/base/1/pg_internal.init'
       [filtered 133 lines of output]
P01 DETAIL: restore file /var/lib/postgresql/17/demo/base/1/113 - exists and matches backup (bundle 20260927-101935F/1/58424, 8KB, 5.90%) checksum 1cd643347b87a472ff001ae124e4b532ce998d2f
P01 DETAIL: restore file /var/lib/postgresql/17/demo/base/1/112 - exists and matches backup (bundle 20260927-101935F/1/58512, 8KB, 5.94%) checksum 2cbd5cf8fb22ef627eb539776c5ec7457bdb2890
P01 DETAIL: restore file /var/lib/postgresql/17/demo/PG_VERSION - exists and matches backup (bundle 20260927-101935F/1/58600, 3B, 5.94%) checksum ad48103e4fc71796e9708cafc43adeed0d1076b7
P01 DETAIL: restore file /var/lib/postgresql/17/demo/global/6303 - exists and matches backup (bundle 20260927-101935F/1/58624, 16KB, 6.01%) checksum f5bab995185b4b5cc2a02777c157dff2937879bf
P01 DETAIL: restore file /var/lib/postgresql/17/demo/global/6302 - exists and matches backup (bundle 20260927-101935F/1/58832, 16KB, 6.08%) checksum eb54339bce7ce3a899043e950ba88034d2450218
       [filtered 869 lines of output]

pg-primary ⇒ Restart PostgreSQL

sudo pg_ctlcluster 17 demo start

Restore Selected Databases

Restore selected databases to improve performance or use a destination with insufficient space for the entire cluster backup.

Create test1 and test2 to demonstrate selective restore.

pg-primary ⇒ Create two test databases

sudo -u postgres psql -c "create database test1;"
CREATE DATABASE
sudo -u postgres psql -c "create database test2;"
CREATE DATABASE

Add tables and data to each test database to verify recovery after selective restore.

pg-primary ⇒ Create a test table in each database

sudo -u postgres psql -c "create table test1_table (id int); \
       insert into test1_table (id) values (1);" test1
CREATE TABLE
INSERT 0 1
sudo -u postgres psql -c "create table test2_table (id int); \
       insert into test2_table (id) values (2);" test2
CREATE TABLE
INSERT 0 1

Take a new backup that includes the new databases.

pg-primary ⇒ Perform a backup

sudo -u postgres pgbackrest --stanza=demo --type=incr backup

Selective restore can save space. Record test1 disk use now for comparison after the restore.

pg-primary ⇒ Show space used by test1 database

sudo -u postgres du -sh /var/lib/postgresql/17/demo/base/32768
7.4M	/var/lib/postgresql/17/demo/base/32768

To find available databases, run info with set to list the backup set contents.

pg-primary ⇒ Show database list for backup

sudo -u postgres pgbackrest --stanza=demo \
       --set=20260927-101935F_20260927-101948I info
       [filtered 12 lines of output]
            repo1: backup size: 1.9MB
            backup reference list: 20260927-101935F, 20260927-101935F_20260927-101941D

            database list: postgres (5), test1 (32768), test2 (32769)

Stop the cluster and restore only the test2 database. Built-in databases (template0, template1, and postgres) are always restored.

WARNING:

Recovery can fail without --type=immediate. After consistency, PostgreSQL treats zeroed pages as errors, even with full-page writes. PostgreSQL ≥ 13 can use ignore_invalid_pages to ignore invalid pages. If you use this setting, check recovery logs for invalid pages in the selected databases.

pg-primary ⇒ Restore from last backup including only the test2 database

sudo pg_ctlcluster 17 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
       --db-include=test2 --type=immediate --target-action=promote restore

sudo pg_ctlcluster 17 demo start

After recovery, test2 contains all previously created tables and data.

pg-primary ⇒ Demonstrate that the test2 database was recovered

sudo -u postgres psql -c "select * from test2_table;" test2
 id
----
  2
(1 row)

Although recovery succeeded, test1 is inaccessible. Its files were restored as sparse, zeroed files. PostgreSQL can replay WAL into them, but empty essential files leave the database invalid. This intentionally prevents use of a database that might contain only partial data from WAL replay.

pg-primary ⇒ Attempting to connect to the test1 database will produce an error

sudo -u postgres psql -c "select * from test1_table;" test1
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  relation mapping file "base/32768/pg_filenode.map" contains invalid data

Sparse, zeroed test1 files use space only for WAL written during recovery. Backup and recovery WAL volumes can be substantial. However, they are usually a small fraction of database size, especially for large databases that benefit most from selective restore.

The selective restore uses much less disk space for test1 than a complete restore would.

pg-primary ⇒ Show space used by test1 database after recovery

sudo -u postgres du -sh /var/lib/postgresql/17/demo/base/32768
8.0K	/var/lib/postgresql/17/demo/base/32768

Only drop database can now operate on invalid test1. pgBackRest does not drop it automatically because this requires completed recovery and an accessible cluster.

pg-primary ⇒ Drop the test1 database

sudo -u postgres psql -c "drop database test1;"
DROP DATABASE

After dropping invalid test1, only test2 and the built-in databases remain.

pg-primary ⇒ List remaining databases

sudo -u postgres psql -c "select oid, datname from pg_database order by oid;"
  oid  |  datname
-------+-----------
     1 | template1
     4 | template0
     5 | postgres

 32769 | test2

(4 rows)

Point-in-Time Recovery

Restore a Backup in Quick Start replayed WAL to the end of the stream. This is usually best after hardware failure. For data corruption caused by machines or people, Point-in-Time Recovery (PITR) is often more suitable.

PITR replays WAL from a backup to a specified LSN, time, transaction ID, or recovery point. Time-based recovery is often the most useful choice. This example recovers an accidentally dropped table. Use the same method for accidentally deleted data.

pg-primary ⇒ Create a table with very important data

sudo -u postgres psql -c "begin; \
       create table important_table (message text); \
       insert into important_table values ('Important Data'); \
       commit; \
       select * from important_table;"
       [filtered 4 lines of output]
    message
----------------

 Important Data

(1 row)

Use PostgreSQL time and include the timezone offset. This reduces unintended timezone conversions and unexpected recovery results.

pg-primary ⇒ Get the time from PostgreSQL

sudo -u postgres psql -Atc "select current_timestamp"
2026-09-27 10:19:58.808792+00

After recording the time, drop the table. In a real incident, the exact drop time can be harder or impossible to find. Investigation should help you estimate it.

pg-primary ⇒ Drop the important table

sudo -u postgres psql -c "begin; \
       drop table important_table; \
       commit; \
       select * from important_table;"
BEGIN
DROP TABLE
COMMITERROR:  relation "important_table" does not exist

LINE 1: ...le important_table;     commit;     select * from important_...
                                                             ^

A backup taken after the target cannot recover to that target. To demonstrate this, take an incremental backup without important_table.

pg-primary ⇒ Perform an incremental backup

sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres pgbackrest info
       [filtered 38 lines of output]
            backup reference total: 1 full, 1 diff
        incr backup: 20260927-101935F_20260927-102000I
            timestamp start/stop: 2026-09-27 10:20:00+00 / 2026-09-27 10:20:01+00
            wal start/stop: 00000004000000000000001A / 00000004000000000000001A
       [filtered 2 lines of output]

This backup cannot recover the lost table. PostgreSQL replays WAL forward and cannot reverse it.

pg-primary ⇒ Attempt recovery from an incorrect backup

sudo pg_ctlcluster 17 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta \
       --set=20260927-101935F_20260927-102000I --target-timeline=current \
       --type=time "--target=2026-09-27 10:19:58.808792+00" --target-action=promote restore

sudo pg_ctlcluster 17 demo start
       [filtered 13 lines of output]
LOG:  database system is ready to accept read-only connections
LOG:  redo done at 0/1A000120 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.03 s

FATAL:  recovery ended before configured recovery target was reached
LOG:  startup process (PID 1440) exited with exit code 1
LOG:  terminating any other active server processes
LOG:  database system is shut down

Let pgBackRest select a backup that completed before the target time and can recover to it.

NOTE:

pgBackRest cannot automatically select a backup when the restore type is xid or name.

pg-primary ⇒ Restore the demo cluster to 2026-08-17 04:51:24.23782+00

sudo -u postgres pgbackrest --stanza=demo --delta \
       --type=time "--target=2026-09-27 10:19:58.808792+00" \
       --target-action=promote restore

sudo -u postgres cat /var/lib/postgresql/17/demo/postgresql.auto.conf
       [filtered 9 lines of output]
# Recovery settings generated by pgBackRest restore on 2026-09-27 10:20:03
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2026-09-27 10:19:58.808792+00'
recovery_target_action = 'promote'

pgBackRest wrote recovery settings to postgresql.auto.conf, so start PostgreSQL immediately. PostgreSQL uses %f for the required WAL segment and %p for its destination. After recovery, the table exists and accepts queries again.

pg-primary ⇒ Start PostgreSQL and check that the important table exists

sudo pg_ctlcluster 17 demo start
sudo -u postgres psql -c "select * from important_table"
    message
----------------

 Important Data

(1 row)

The PostgreSQL log shows the recovery stop time and transaction. It also shows the time of the last applied transaction.

pg-primary ⇒ Examine the PostgreSQL log output

sudo -u postgres cat /var/log/postgresql/postgresql-17-demo.log
       [filtered 7 lines of output]
LOG:  restored log file "00000004.history" from archive
LOG:  restored log file "000000040000000000000019" from archive
LOG:  starting point-in-time recovery to 2026-09-27 10:19:58.808792+00
LOG:  restored log file "00000003.history" from archive
LOG:  redo starts at 0/19000028
       [filtered 2 lines of output]
LOG:  database system is ready to accept read-only connections
LOG:  restored log file "00000004000000000000001A" from archive
LOG:  recovery stopping before commit of transaction 748, time 2026-09-27 10:20:00.041047+00
LOG:  redo done at 0/1901CC00 system usage: CPU: user: 0.00 s, system: 0.01 s, elapsed: 0.07 s
LOG:  last completed transaction was at log time 2026-09-27 10:19:57.537628+00
LOG:  restored log file "000000040000000000000019" from archive
LOG:  selected new timeline ID: 5
       [filtered 5 lines of output]

Delete a Stanza

The stanza-delete command removes repository data for a stanza.

WARNING:

Use this command with care. It permanently removes every backup and archive for the specified stanza from the pgBackRest repository.

To delete a stanza:

  • Shut down the PostgreSQL cluster associated with the stanza (or use –force to override).
  • Run the stop command on the host where the stanza-delete command will be run.
  • Run the stanza-delete command.

After the command succeeds, remove the stanza from all applicable pgBackRest configuration files and environment variables.

Delete a stanza from one repository at a time. For multiple repositories, repeat stanza-delete with --repo for each repository.

pg-primary ⇒ Stop PostgreSQL cluster to be removed

sudo pg_ctlcluster 17 demo stop

pg-primary ⇒ Stop pgBackRest for the stanza

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stop
P00   INFO: stop command begin 2.59.2: --exec-id=1572-06fe3d27 --log-level-console=info --no-log-timestamp --stanza=demo

P00   INFO: stop command end: completed successfully

pg-primary ⇒ Delete the stanza from one repository

sudo -u postgres pgbackrest --stanza=demo --repo=1 \
       --log-level-console=info stanza-delete
P00   INFO: stanza-delete command begin 2.59.2: --exec-id=1580-c06f14e0 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo=1 --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo

P00   INFO: stanza-delete command end: completed successfully

Multiple Repositories

Configure multiple repositories as shown in S3 Support. For example, use a local repository for fast restores and a remote repository for redundancy.

Commands such as stanza-create and stanza-upgrade automatically use all repositories. Others, such as stanza-delete, require a repo selection.

For compatibility, repo is optional when only repo1 is configured. It is required when the only repository has another index, such as repo2. This prevents command failures if another repository is added later.

archive-push sends WAL to all configured repositories. If one is unreachable, it still sends WAL to the others. Enable archive-async=y for effective independent progress. Otherwise, the other repositories can advance only one segment beyond the unreachable repository. If WAL cannot reach any repository, PostgreSQL keeps it in pg_wal. This can fill the volume.

Schedule backups separately for each repository. This lets you vary backup types and retention. Specify a repository for restores as well. A repository with low latency or cost is usually preferable, even with longer recovery time. Test restores to determine which is most efficient.


Azure-Compatible Object Store Support

pgBackRest supports repositories in Azure-compatible object stores. Create the container first; pgBackRest does not create it. You can use the container root (/). Usually, prefer a subpath so object-store logs and other data can share the container without conflicts.

WARNING:

Do not enable “hierarchical namespace” as this will cause errors during expire.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure Azure

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
repo2-azure-account=pgbackrest
repo2-azure-container=demo-container
repo2-azure-key=YXpLZXk=
repo2-path=/demo-repo
repo2-retention-full=4
repo2-type=azure
start-fast=y
[global:archive-push]
compress-level=3

For a shared access signature, set repo2-azure-key-type to sas. Set repo2-azure-key to the signature token.

Run commands as you would for a repository on a local disk.

pg-primary ⇒ Create the stanza

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00   INFO: stanza-create command begin 2.59.2: --exec-id=1661-eeb7ca7a --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo2-type=azure --stanza=demo
P00   INFO: stanza-create for stanza 'demo' on repo1
P00   INFO: stanza-create for stanza 'demo' on repo2

P00   INFO: stanza-create command end: completed successfully

Azure file creation is relatively slow. Enable file bundling to improve backup/restore performance.

pg-primary ⇒ Backup the demo cluster

sudo -u postgres pgbackrest --stanza=demo --repo=2 \
       --log-level-console=info backup
P00   INFO: backup command begin 2.59.2: --exec-id=1670-de551bc3 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo=2 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-block --repo1-bundle --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo2-type=azure --stanza=demo --start-fast

P00   WARN: no prior backup exists, incr backup has been changed to full

P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 00000005000000000000001B, lsn = 0/1B000028
       [filtered 3 lines of output]
P00   INFO: check archive for segment(s) 00000005000000000000001B:00000005000000000000001B
P00   INFO: new backup label = 20260927-102014F

P00   INFO: full backup size = 29.2MB, file total = 1265

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=1670-de551bc3 --log-level-console=info --no-log-timestamp --repo=2 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo2-type=azure --stanza=demo

S3-Compatible Object Store Support

pgBackRest supports repositories in S3-compatible object stores. Create the bucket first; pgBackRest does not create it. You can use the bucket root (/). Usually, prefer a subpath so object-store logs and other data can share the bucket without conflicts.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure S3

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
repo2-azure-account=pgbackrest
repo2-azure-container=demo-container
repo2-azure-key=YXpLZXk=
repo2-path=/demo-repo
repo2-retention-full=4
repo2-type=azure
repo3-path=/demo-repo
repo3-retention-full=4
repo3-s3-bucket=demo-bucket
repo3-s3-endpoint=s3.us-east-1.amazonaws.com
repo3-s3-key=accessKey1
repo3-s3-key-secret=verySecretKey1
repo3-s3-region=us-east-1
repo3-type=s3
start-fast=y
[global:archive-push]
compress-level=3

NOTE:

Set the region and endpoint for the bucket location. These examples use us-east-1.

Create a role for pgBackRest and restrict bucket permissions as much as possible. For an AWS instance-associated role, set repo3-s3-key-type=auto to retrieve temporary credentials automatically. You then do not need explicit keys in /etc/pgbackrest/pgbackrest.conf.

This sample Amazon S3 policy will restrict all reads and writes to the bucket and repository path.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::demo-bucket"
            ],
            "Condition": {
                "StringEquals": {
                    "s3:prefix": [
                        "",
                        "demo-repo"
                    ],
                    "s3:delimiter": [
                        "/"
                    ]
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::demo-bucket"
            ],
            "Condition": {
                "StringLike": {
                    "s3:prefix": [
                        "demo-repo/*"
                    ]
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:PutObjectTagging",
                "s3:GetObject",
                "s3:GetObjectVersion",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::demo-bucket/demo-repo/*"
            ]
        }
    ]
}

Run commands as you would for a repository on a local disk.

pg-primary ⇒ Create the stanza

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
       [filtered 4 lines of output]
P00   INFO: stanza 'demo' already exists on repo2 and is valid
P00   INFO: stanza-create for stanza 'demo' on repo3

P00   INFO: stanza-create command end: completed successfully

S3 file creation is relatively slow. Enable file bundling to improve backup/restore performance.

pg-primary ⇒ Backup the demo cluster

sudo -u postgres pgbackrest --stanza=demo --repo=3 \
       --log-level-console=info backup
P00   INFO: backup command begin 2.59.2: --exec-id=1773-e5dfef6d --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo=3 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-block --repo1-bundle --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo2-type=azure --repo3-type=s3 --stanza=demo --start-fast

P00   WARN: no prior backup exists, incr backup has been changed to full

P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 00000005000000000000001D, lsn = 0/1D000028
       [filtered 3 lines of output]
P00   INFO: check archive for segment(s) 00000005000000000000001D:00000005000000000000001D
P00   INFO: new backup label = 20260927-102029F

P00   INFO: full backup size = 29.2MB, file total = 1265

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=1773-e5dfef6d --log-level-console=info --no-log-timestamp --repo=3 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo2-type=azure --repo3-type=s3 --stanza=demo

SFTP Support

pgBackRest supports repositories on SFTP hosts. SFTP transfers are relatively slow. Increase process-max to transfer files in parallel.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure SFTP

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
process-max=4
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
repo2-azure-account=pgbackrest
repo2-azure-container=demo-container
repo2-azure-key=YXpLZXk=
repo2-path=/demo-repo
repo2-retention-full=4
repo2-type=azure
repo3-path=/demo-repo
repo3-retention-full=4
repo3-s3-bucket=demo-bucket
repo3-s3-endpoint=s3.us-east-1.amazonaws.com
repo3-s3-key=accessKey1
repo3-s3-key-secret=verySecretKey1
repo3-s3-region=us-east-1
repo3-type=s3
repo4-bundle=y
repo4-path=/demo-repo
repo4-sftp-host=sftp-server
repo4-sftp-host-key-hash-type=sha1
repo4-sftp-host-user=pgbackrest
repo4-sftp-private-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp
repo4-sftp-public-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp.pub
repo4-type=sftp
start-fast=y
[global:archive-push]
compress-level=3

For SFTP with libssh2 compiled against OpenSSH, repo4-sftp-public-key-file is optional.

pg-primary ⇒ Generate SSH keypair for SFTP backup

sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa_sftp \
       -t rsa -b 4096 -N "" -m PEM

sftp-server ⇒ Copy pg-primary SFTP backup public key to sftp-server

sudo -u pgbackrest mkdir -m 750 -p /home/pgbackrest/.ssh

(sudo ssh root@pg-primary cat /var/lib/postgresql/.ssh/id_rsa_sftp.pub) | \
       sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys

Run commands as you would for a repository on a local disk.

pg-primary ⇒ Add sftp-server fingerprint to known_hosts file since repo4-sftp-host-key-check-type defaults to “strict”

ssh-keyscan -H sftp-server >> /var/lib/postgresql/.ssh/known_hosts 2>/dev/null

pg-primary ⇒ Create the stanza

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
       [filtered 6 lines of output]
P00   INFO: stanza 'demo' already exists on repo3 and is valid
P00   INFO: stanza-create for stanza 'demo' on repo4

P00   INFO: stanza-create command end: completed successfully

pg-primary ⇒ Backup the demo cluster

sudo -u postgres pgbackrest --stanza=demo --repo=4 \
       --log-level-console=info backup
P00   INFO: backup command begin 2.59.2: --exec-id=1862-9e493c8b --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --process-max=4 --repo=4 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-block --repo1-bundle --repo4-bundle --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo4-sftp-host=sftp-server --repo4-sftp-host-key-hash-type=sha1 --repo4-sftp-host-user=pgbackrest --repo4-sftp-private-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp.pub --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --stanza=demo --start-fast
P00   WARN: option 'repo4-retention-full' is not set for 'repo4-retention-full-type=count', the repository may run out of space
            HINT: to retain full backups indefinitely (without warning), set option 'repo4-retention-full' to the maximum.

P00   WARN: no prior backup exists, incr backup has been changed to full

P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 00000005000000000000001E, lsn = 0/1E000028
       [filtered 3 lines of output]
P00   INFO: check archive for segment(s) 00000005000000000000001E:00000005000000000000001F
P00   INFO: new backup label = 20260927-102048F

P00   INFO: full backup size = 29.2MB, file total = 1265

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=1862-9e493c8b --log-level-console=info --no-log-timestamp --repo=4 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo4-sftp-host=sftp-server --repo4-sftp-host-key-hash-type=sha1 --repo4-sftp-host-user=pgbackrest --repo4-sftp-private-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp.pub --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --stanza=demo
P00   INFO: expire command end: completed successfully

GCS-Compatible Object Store Support

pgBackRest supports repositories in GCS-compatible object stores. Create the bucket first; pgBackRest does not create it. You can use the bucket root (/). Usually, prefer a subpath so object-store logs and other data can share the bucket without conflicts.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure GCS

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
process-max=4
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
repo2-azure-account=pgbackrest
repo2-azure-container=demo-container
repo2-azure-key=YXpLZXk=
repo2-path=/demo-repo
repo2-retention-full=4
repo2-type=azure
repo3-path=/demo-repo
repo3-retention-full=4
repo3-s3-bucket=demo-bucket
repo3-s3-endpoint=s3.us-east-1.amazonaws.com
repo3-s3-key=accessKey1
repo3-s3-key-secret=verySecretKey1
repo3-s3-region=us-east-1
repo3-type=s3
repo4-bundle=y
repo4-path=/demo-repo
repo4-sftp-host=sftp-server
repo4-sftp-host-key-hash-type=sha1
repo4-sftp-host-user=pgbackrest
repo4-sftp-private-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp
repo4-sftp-public-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp.pub
repo4-type=sftp
repo5-gcs-bucket=demo-bucket
repo5-gcs-key=/etc/pgbackrest/gcs-key.json
repo5-path=/demo-repo
repo5-type=gcs
start-fast=y
[global:archive-push]
compress-level=3

On GCE, set repo5-gcs-key-type=auto to authenticate through the instance service account.

Run commands as you would for a repository on a local disk.

GCS file creation is relatively slow. Enable file bundling to improve backup/restore performance.


Target Time for Repository

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

Delete the S3 repository demo stanza to demonstrate recovery from versioned storage.

pg-primary ⇒ Delete stanza in S3 repository

sudo pg_ctlcluster 17 demo stop
sudo -u postgres pgbackrest --stanza=demo stop
sudo -u postgres pgbackrest --stanza=demo --repo=3 stanza-delete

After deletion, info reports a repository error.

pg-primary ⇒ Error on info

sudo -u postgres pgbackrest --stanza=demo --repo=3 info
stanza: demo

    status: error (missing stanza path)

Versioned storage lets you read the repository before deletion. Finding the target time can be difficult. Here, use the deletion time of backup.info to identify when the stanza was deleted.

pg-primary ⇒ List versions of backup.info in the bucket

key=demo-repo/backup/demo/backup.info; \
       aws s3api list-object-versions --bucket demo-bucket \
       --prefix $key --output table \
       --query "sort_by([Versions[?Key=='$key'].{Action:'PUT', \
       Modified:LastModified,Object:Key}, \
       DeleteMarkers[?Key=='$key'].{Action:'DELETE', \
       Modified:LastModified,Object:Key}][],&Modified)"
-----------------------------------------------------------------------------
|                            ListObjectVersions                             |
+--------+----------------------------+-------------------------------------+
| Action |         Modified           |               Object                |
+--------+----------------------------+-------------------------------------+
|  PUT   |  2026-09-27T10:20:29.313Z  |  demo-repo/backup/demo/backup.info  |
|  PUT   |  2026-09-27T10:20:43.618Z  |  demo-repo/backup/demo/backup.info  |
|  DELETE|  2026-09-27T10:20:53.763Z  |  demo-repo/backup/demo/backup.info  |
+--------+----------------------------+-------------------------------------+

Run info with a target time before deletion to view the repository.

pg-primary ⇒ Info with target time

sudo -u postgres pgbackrest --stanza=demo --repo=3 \
       --repo-target-time="2026-09-27 10:20:43+00" info
       [filtered 5 lines of output]
        wal archive min/max (17): 00000005000000000000001C/00000005000000000000001D
        full backup: 20260927-102029F
            timestamp start/stop: 2026-09-27 10:20:29+00 / 2026-09-27 10:20:43+00
            wal start/stop: 00000005000000000000001D / 00000005000000000000001D
            repo3: backup set size: 3.8MB, backup size: 3.8MB

If info shows the required backup, restore it with the same target time.

pg-primary ⇒ Restore with target time

sudo -u postgres pgbackrest --stanza=demo --repo=3 --delta \
       --repo-target-time="2026-09-27 10:20:43+00" --log-level-console=info restore
P00   INFO: restore command begin 2.59.2: --delta --exec-id=1956-05298d4c --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --process-max=4 --repo=3 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo5-gcs-bucket=demo-bucket --repo5-gcs-key=<redacted> --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo5-path=/demo-repo --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo4-sftp-host=sftp-server --repo4-sftp-host-key-hash-type=sha1 --repo4-sftp-host-user=pgbackrest --repo4-sftp-private-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/postgresql/.ssh/id_rsa_sftp.pub --repo-target-time="2026-09-27 10:20:43+00" --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --repo5-type=gcs --stanza=demo
P00   INFO: repo3: restore backup set 20260927-102029F, recovery will start at 2026-09-27 10:20:29

P00   INFO: remove invalid files/links/paths from '/var/lib/postgresql/17/demo'
P00   INFO: write updated /var/lib/postgresql/17/demo/postgresql.auto.conf
       [filtered 2 lines of output]
sudo pg_ctlcluster 17 demo start

Dedicated Repository Host

Quickstart suits simple installations. Enterprise installations commonly use a separate repository host for backups and WAL archives. This reduces the effect of database host failures on backup data. Also consider conventional backup software for the repository host.

On each PostgreSQL host, set pg1-path to the local cluster path and leave pg1-host unset. On the repository host, configure pg-host connections to the primary and any standby hosts. Only the repository host configuration should list multiple PostgreSQL hosts. Either index can identify the primary or standby; for example, pg1-path/pg1-host and pg2-path/pg2-host can appear in either order.

Installation

Create a host named repository to store cluster backups.

NOTE:

The pgBackRest version installed on the repository host must exactly match the version installed on the PostgreSQL host.

Create pgbackrest as the repository owner. Any user can own it, but avoid postgres, if present, to prevent confusion.

NOTE:

A pgBackRest package might install logrotate configuration, such as /etc/logrotate.d/pgbackrest, with a su directive like su postgres postgres. Files in /var/log/pgbackrest belong to the user running pgBackRest, here pgbackrest. Update su to that user. Otherwise, logrotate fails with a permission error.

repository ⇒ Create pgbackrest user

sudo adduser --disabled-password --gecos "" pgbackrest

Prefer package installation to a source build. Packages usually perform the remaining steps in this section. If a package omits a directory or sets incorrect permissions, create the directory or correct its permissions manually.

Debian/Ubuntu packages for pgBackRest are available at apt.postgresql.org.

If your distribution or version has no package, build from source and follow these manual installation steps.

repository ⇒ Install dependencies

sudo apt-get install postgresql-client libxml2 libssh2-1

repository ⇒ Copy pgBackRest binary from build host

sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest

pgBackRest requires log and configuration directories and a configuration file.

repository ⇒ Create pgBackRest configuration file and directories

sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown pgbackrest:pgbackrest /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown pgbackrest:pgbackrest /etc/pgbackrest/pgbackrest.conf

repository ⇒ Create the pgBackRest repository

sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown pgbackrest:pgbackrest /var/lib/pgbackrest

Setup Passwordless SSH

Use passwordless SSH for communication between hosts. TLS is also supported; see Setup TLS.

repository ⇒ Create repository host key pair

sudo -u pgbackrest mkdir -m 750 /home/pgbackrest/.ssh
sudo -u pgbackrest ssh-keygen -f /home/pgbackrest/.ssh/id_rsa \
       -t rsa -b 4096 -N ""

pg-primary ⇒ Create pg-primary host key pair

sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa \
       -t rsa -b 4096 -N ""

Exchange keys between repository and pg-primary.

repository ⇒ Copy pg-primary public key to repository

(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \
       echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \
       sudo ssh root@pg-primary cat /var/lib/postgresql/.ssh/id_rsa.pub) | \
       sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys

pg-primary ⇒ Copy repository public key to pg-primary

(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \
       echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \
       sudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub) | \
       sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keys

Test connections from repository to pg-primary and from pg-primary to repository.

repository ⇒ Test connection from repository to pg-primary

sudo -u pgbackrest ssh postgres@pg-primary

pg-primary ⇒ Test connection from pg-primary to repository

sudo -u postgres ssh pgbackrest@repository

NOTE:

Passwordless SSH now permits only pgBackRest commands. This limits access if a service account is compromised.

Configuration

On the repository host, configure the pg-primary host, user, and database path. Use pg1 for the primary so you can add a standby later.

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pg1-host/pg1-host-user and pg1-path

[demo]
pg1-host=pg-primary
pg1-path=/var/lib/postgresql/17/demo
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y

On the database host, configure the repository host and user. repo1-host-user defaults to pgbackrest. If postgres performs restores on the repository host, preferably prevent it from also performing backups. It can read the repository directly if it belongs to the pgbackrest group.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-host/repo1-host-user

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
log-level-file=detail
repo1-host=repository

See Configure Archiving for PostgreSQL configuration.

Commands work as in a single-host setup. However, run commands such as backup and expire on the repository host.

Create and Check Stanza

Create the stanza in the new repository.

repository ⇒ Create the stanza

sudo -u pgbackrest pgbackrest --stanza=demo stanza-create

Check configuration on both the database and repository hosts. See Check the Configuration for check details.

pg-primary ⇒ Check the configuration

sudo -u postgres pgbackrest --stanza=demo check

repository ⇒ Check the configuration

sudo -u pgbackrest pgbackrest --stanza=demo check

Perform a Backup

On the repository host, run pgBackRest backup to back up the PostgreSQL cluster.

repository ⇒ Backup the demo cluster

sudo -u pgbackrest pgbackrest --stanza=demo backup
P00   WARN: no prior backup exists, incr backup has been changed to full

The new repository had no full backup. pgBackRest therefore warned that it changed the incremental backup to a full backup.

Restore a Backup

On the database host, run pgBackRest restore to restore the PostgreSQL cluster.

pg-primary ⇒ Stop the demo cluster, restore, and restart PostgreSQL

sudo pg_ctlcluster 17 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo pg_ctlcluster 17 demo start

Parallel Backup / Restore

pgBackRest can compress and transfer data in parallel. Set the process count with --process-max.

Usually, allocate no more than 25% of available CPUs to backup. Regular backups do not need maximum speed. Avoid reducing database performance where possible.

Restore should use all available CPUs because PostgreSQL is stopped and usually no other critical work runs on that host. If the host has multiple clusters, account for them when setting parallelism.

repository ⇒ Perform a backup with single process

sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pgBackRest to use multiple backup processes

[demo]
pg1-host=pg-primary
pg1-path=/var/lib/postgresql/17/demo
[global]
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y

repository ⇒ Perform a backup with multiple processes

sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup

repository ⇒ Get backup info for the demo cluster

sudo -u pgbackrest pgbackrest info
stanza: demo
    status: ok
    cipher: none

    db (current)
        wal archive min/max (17): 000000070000000000000023/000000070000000000000025

        full backup: 20260927-102128F
            timestamp start/stop: 2026-09-27 10:21:28+00 / 2026-09-27 10:21:32+00

            wal start/stop: 000000070000000000000023 / 000000070000000000000023
            database size: 29.2MB, database backup size: 29.2MB
            repo1: backup set size: 3.8MB, backup size: 3.8MB

        full backup: 20260927-102135F
            timestamp start/stop: 2026-09-27 10:21:35+00 / 2026-09-27 10:21:38+00

            wal start/stop: 000000070000000000000024 / 000000070000000000000025
            database size: 29.2MB, database backup size: 29.2MB
            repo1: backup set size: 3.8MB, backup size: 3.8MB

Multiple processes should speed up the last backup. For very small backups, the difference might be small. Time savings increase with database size.


Starting and Stopping

Prevent test clusters from writing to pgBackRest repositories with stop. This includes standbys promoted for testing and test clusters restored from production backups.

stop blocks these write commands: archive-push, backup, expire, stanza-create, and stanza-upgrade. The exception is stanza-delete; see Delete a Stanza.

pg-primary ⇒ Stop pgBackRest write commands

sudo -u postgres pgbackrest stop

New pgBackRest write commands cannot run.

repository ⇒ Attempt a backup

sudo -u pgbackrest pgbackrest --stanza=demo backup
P00   WARN: unable to check pg1: [StopError] raised from remote-0 ssh protocol on 'pg-primary': stop file exists for all stanzas

P00  ERROR: [056]: unable to find primary cluster - cannot proceed
            HINT: are all available clusters in recovery?

Use --force to terminate running pgBackRest write commands. This also terminates asynchronous archive-get, although it restarts if PostgreSQL needs it. Repeating stop when pgBackRest is already stopped produces a warning.

pg-primary ⇒ Stop the pgBackRest services again

sudo -u postgres pgbackrest stop
P00   WARN: stop file already exists for all stanzas

Use start to permit pgBackRest write commands again. Previously interrupted commands do not restart automatically.

pg-primary ⇒ Start pgBackRest write commands

sudo -u postgres pgbackrest start

You can also stop pgBackRest for one stanza.

pg-primary ⇒ Stop pgBackRest write commands for the demo stanza

sudo -u postgres pgbackrest --stanza=demo stop

New pgBackRest write commands cannot run for this stanza.

repository ⇒ Attempt a backup

sudo -u pgbackrest pgbackrest --stanza=demo backup
P00   WARN: unable to check pg1: [StopError] raised from remote-0 ssh protocol on 'pg-primary': stop file exists for stanza demo

P00  ERROR: [056]: unable to find primary cluster - cannot proceed
            HINT: are all available clusters in recovery?

When starting write commands for one stanza, specify that stanza again.

pg-primary ⇒ Start pgBackRest write commands for the demo stanza

sudo -u postgres pgbackrest --stanza=demo start

Replication

Replication creates standby copies of a PostgreSQL primary cluster. Standbys distribute read load and provide redundancy if the primary host fails.

Installation

Create a host named pg-standby for the standby.

Prefer package installation to a source build. Packages usually perform the remaining steps in this section. If a package omits a directory or sets incorrect permissions, create the directory or correct its permissions manually.

Debian/Ubuntu packages for pgBackRest are available at apt.postgresql.org.

If your distribution or version has no package, build from source and follow these manual installation steps.

pg-standby ⇒ Install dependencies

sudo apt-get install postgresql-client libxml2 libssh2-1

pg-standby ⇒ Copy pgBackRest binary from build host

sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest

pgBackRest requires log and configuration directories and a configuration file.

pg-standby ⇒ Create pgBackRest configuration file and directories

sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf

Setup Passwordless SSH

Use passwordless SSH for communication between hosts. TLS is also supported; see Setup TLS.

pg-standby ⇒ Create pg-standby host key pair

sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa \
       -t rsa -b 4096 -N ""

Exchange keys between repository and pg-standby.

repository ⇒ Copy pg-standby public key to repository

(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \
       echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \
       sudo ssh root@pg-standby cat /var/lib/postgresql/.ssh/id_rsa.pub) | \
       sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys

pg-standby ⇒ Copy repository public key to pg-standby

(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \
       echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \
       sudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub) | \
       sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keys

Test connections from repository to pg-standby and from pg-standby to repository.

repository ⇒ Test connection from repository to pg-standby

sudo -u pgbackrest ssh postgres@pg-standby

pg-standby ⇒ Test connection from pg-standby to repository

sudo -u postgres ssh pgbackrest@repository

Hot Standby

A hot standby performs replication using the WAL archive and allows read-only queries.

Use configuration similar to pg-primary. Set recovery type standby to keep the cluster in recovery after it reaches the end of archived WAL.

pg-standby:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pgBackRest on the standby

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
log-level-file=detail
repo1-host=repository

Create the demo cluster to generate PostgreSQL configuration files. The restore will overwrite the cluster.

pg-standby ⇒ Create demo cluster

sudo pg_createcluster 17 demo

Create the standby with restore.

IMPORTANT:

If promotion is for testing or reporting rather than a new primary, disable archiving. Use --archive-mode=off or set archive_mode=off in postgresql.conf. Otherwise, the cluster can add conflicting WAL to the repository and complicate restores.

pg-standby ⇒ Restore the demo standby cluster

sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/postgresql/17/demo/postgresql.auto.conf

# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:19:18
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:19:43
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:20:03
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
# Removed by pgBackRest restore on 2026-09-27 10:20:57 # recovery_target_time = '2026-09-27 10:19:58.808792+00'
# Removed by pgBackRest restore on 2026-09-27 10:20:57 # recovery_target_action = 'promote'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:20:57
restore_command = 'pgbackrest --repo=3 --repo-target-time="2026-09-27 10:20:43+00" --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:21:22
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:21:53
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

This configuration also supports later promotion of the standby to primary.

pg-standby:/etc/postgresql/17/demo/postgresql.conf ⇒ Configure PostgreSQL

archive_command = 'pgbackrest --stanza=demo archive-push %p'
archive_mode = on

pg-standby ⇒ Start PostgreSQL

sudo pg_ctlcluster 17 demo start

Check the PostgreSQL recovery log. It should show that the cluster entered standby mode and accepts read-only connections.

pg-standby ⇒ Examine the PostgreSQL log output for log messages indicating success

sudo -u postgres cat /var/log/postgresql/postgresql-17-demo.log
       [filtered 6 lines of output]
LOG:  restored log file "00000007.history" from archive
LOG:  restored log file "000000070000000000000024" from archive

LOG:  entering standby mode

LOG:  redo starts at 0/24000028
LOG:  restored log file "000000070000000000000025" from archive
       [filtered 3 lines of output]

To test replication, create a table on pg-primary.

pg-primary ⇒ Create a new table on the primary

sudo -u postgres psql -c " \
       begin; \
       create table replicated_table (message text); \
       insert into replicated_table values ('Important Data'); \
       commit; \
       select * from replicated_table";
       [filtered 4 lines of output]
    message
----------------

 Important Data

(1 row)

Then query that table on pg-standby.

pg-standby ⇒ Query new table on the standby

sudo -u postgres psql -c "select * from replicated_table;"
ERROR:  relation "replicated_table" does not exist

LINE 1: select * from replicated_table;
                      ^

The standby reads archived WAL. It cannot see changes until pg-primary archives the segment containing them.

Call pg_switch_wal() to archive the current WAL segment. PostgreSQL creates a new segment for later changes.

pg-primary ⇒ Call pg_switch_wal()

sudo -u postgres psql -c "select *, current_timestamp from pg_switch_wal()";
 pg_switch_wal |       current_timestamp
---------------+-------------------------------
 0/260195C8    | 2026-09-27 10:22:00.645267+00
(1 row)

After a short delay, the table appears on pg-standby.

pg-standby ⇒ Now the new table exists on the standby (may require a few retries)

sudo -u postgres psql -c " \
       select *, current_timestamp from replicated_table"
    message     |       current_timestamp
----------------+-------------------------------
 Important Data | 2026-09-27 10:22:02.144747+00

(1 row)

Check the standby configuration for access to the repository.

pg-standby ⇒ Check the configuration

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=515-943c4c3c --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo1-host=repository --stanza=demo
P00   INFO: check repo1 (standby)

P00   INFO: switch wal not performed because this is a standby

P00   INFO: check command end: completed successfully

Streaming Replication

Streaming replication connects directly to the primary and applies changes as they occur. This reduces primary-to-standby lag compared with archive-only replication.

Streaming replication requires a user with the replication privilege.

pg-primary ⇒ Create replication user

sudo -u postgres psql -c " \
       create user replicator password 'jw8s0F4' replication";
CREATE ROLE

Update pg_hba.conf to allow the standby to connect as the replication user. Replace the example IP address with your pg-standby address. Reload configuration after the change.

pg-primary ⇒ Create pg_hba.conf entry for replication user

sudo -u postgres sh -c 'echo \
       "host    replication     replicator      172.17.0.8/32           md5" \
       >> /etc/postgresql/17/demo/pg_hba.conf'

sudo pg_ctlcluster 17 demo reload

Configure primary_conninfo in pgBackRest so the standby can contact the primary.

pg-standby:/etc/pgbackrest/pgbackrest.conf ⇒ Set primary_conninfo

[demo]
pg1-path=/var/lib/postgresql/17/demo
recovery-option=primary_conninfo=host=172.17.0.6 port=5432 user=replicator
[global]
log-level-file=detail
repo1-host=repository

You can put a password in primary_conninfo, but a .pgpass file is more flexible and secure.

pg-standby ⇒ Configure the replication password in the .pgpass file.

sudo -u postgres sh -c 'echo \
       "172.17.0.6:*:replication:replicator:jw8s0F4" \
       >> /var/lib/postgresql/.pgpass'

sudo -u postgres chmod 600 /var/lib/postgresql/.pgpass

Create the standby with restore.

pg-standby ⇒ Stop PostgreSQL and restore the demo standby cluster

sudo pg_ctlcluster 17 demo stop
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/postgresql/17/demo/postgresql.auto.conf

# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:19:18
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:19:43
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:20:03
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
# Removed by pgBackRest restore on 2026-09-27 10:20:57 # recovery_target_time = '2026-09-27 10:19:58.808792+00'
# Removed by pgBackRest restore on 2026-09-27 10:20:57 # recovery_target_action = 'promote'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:20:57
restore_command = 'pgbackrest --repo=3 --repo-target-time="2026-09-27 10:20:43+00" --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:21:22
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:22:05
primary_conninfo = 'host=172.17.0.6 port=5432 user=replicator'
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

NOTE:

pgBackRest wrote primary_conninfo to postgresql.auto.conf because pgbackrest.conf defines it as a recovery-option. To preserve an existing postgresql.auto.conf, run restore with --type=preserve.

pg-standby ⇒ Start PostgreSQL

sudo pg_ctlcluster 17 demo start

Check the PostgreSQL log to confirm that streaming replication started.

pg-standby ⇒ Examine the PostgreSQL log output for log messages indicating success

sudo -u postgres cat /var/log/postgresql/postgresql-17-demo.log
       [filtered 13 lines of output]
LOG:  consistent recovery state reached at 0/25000088
LOG:  database system is ready to accept read-only connections

LOG:  started streaming WAL from primary at 0/27000000 on timeline 7

New tables on pg-primary now appear quickly on pg-standby without pg_switch_wal().

pg-primary ⇒ Create a new table on the primary

sudo -u postgres psql -c " \
       begin; \
       create table stream_table (message text); \
       insert into stream_table values ('Important Data'); \
       commit; \
       select *, current_timestamp from stream_table";
       [filtered 4 lines of output]
    message     |       current_timestamp
----------------+-------------------------------
 Important Data | 2026-09-27 10:22:11.713263+00

(1 row)

pg-standby ⇒ Query table on the standby

sudo -u postgres psql -c " \
       select *, current_timestamp from stream_table"
    message     |      current_timestamp
----------------+------------------------------
 Important Data | 2026-09-27 10:22:11.89181+00

(1 row)

Multiple Stanzas

pgBackRest supports multiple stanzas, commonly with one shared repository host.

Installation

Create a host named pg-alt for the new primary.

Prefer package installation to a source build. Packages usually perform the remaining steps in this section. If a package omits a directory or sets incorrect permissions, create the directory or correct its permissions manually.

Debian/Ubuntu packages for pgBackRest are available at apt.postgresql.org.

If your distribution or version has no package, build from source and follow these manual installation steps.

pg-alt ⇒ Install dependencies

sudo apt-get install postgresql-client libxml2 libssh2-1

pg-alt ⇒ Copy pgBackRest binary from build host

sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest

pgBackRest requires log and configuration directories and a configuration file.

pg-alt ⇒ Create pgBackRest configuration file and directories

sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf

Setup Passwordless SSH

Use passwordless SSH for communication between hosts. TLS is also supported; see Setup TLS.

pg-alt ⇒ Create pg-alt host key pair

sudo -u postgres mkdir -m 750 -p /var/lib/postgresql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/postgresql/.ssh/id_rsa \
       -t rsa -b 4096 -N ""

Exchange keys between repository and pg-alt.

repository ⇒ Copy pg-alt public key to repository

(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \
       echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \
       sudo ssh root@pg-alt cat /var/lib/postgresql/.ssh/id_rsa.pub) | \
       sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys

pg-alt ⇒ Copy repository public key to pg-alt

(echo -n 'no-agent-forwarding,no-X11-forwarding,no-port-forwarding,' && \
       echo -n 'command="/usr/bin/pgbackrest ${SSH_ORIGINAL_COMMAND#* }" ' && \
       sudo ssh root@repository cat /home/pgbackrest/.ssh/id_rsa.pub) | \
       sudo -u postgres tee -a /var/lib/postgresql/.ssh/authorized_keys

Test connections from repository to pg-alt and from pg-alt to repository.

repository ⇒ Test connection from repository to pg-alt

sudo -u pgbackrest ssh postgres@pg-alt

pg-alt ⇒ Test connection from pg-alt to repository

sudo -u postgres ssh pgbackrest@repository

Configuration

Use configuration similar to pg-primary, but select stanza demo-alt. This separates its backups and archive.

pg-alt:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pgBackRest on the new primary

[demo-alt]
pg1-path=/var/lib/postgresql/17/demo
[global]
log-level-file=detail
repo1-host=repository

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pg1-host/pg1-host-user and pg1-path

[demo]
pg1-host=pg-primary
pg1-path=/var/lib/postgresql/17/demo
[demo-alt]
pg1-host=pg-alt
pg1-path=/var/lib/postgresql/17/demo
[global]
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y

Setup Demo Cluster

pg-alt ⇒ Create the demo cluster

sudo -u postgres /usr/lib/postgresql/17/bin/initdb \
       -D /var/lib/postgresql/17/demo -k -A peer

sudo pg_createcluster 17 demo
Configuring already existing cluster (configuration: /etc/postgresql/17/demo, data: /var/lib/postgresql/17/demo, owner: 102:103)
Ver Cluster Port Status Owner    Data directory              Log file
17  demo    5432 down   postgres /var/lib/postgresql/17/demo /var/log/postgresql/postgresql-17-demo.log

pg-alt:/etc/postgresql/17/demo/postgresql.conf ⇒ Configure PostgreSQL settings

archive_command = 'pgbackrest --stanza=demo-alt archive-push %p'
archive_mode = on

pg-alt ⇒ Start the demo cluster

sudo pg_ctlcluster 17 demo restart

Create the Stanza and Check Configuration

Run stanza-create to initialize the stanza. Then run check to verify archive and backup configuration.

pg-alt ⇒ Create the stanza and check the configuration

sudo -u postgres pgbackrest --stanza=demo-alt --log-level-console=info stanza-create
P00   INFO: stanza-create command begin 2.59.2: --exec-id=382-63e4cb56 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo1-host=repository --stanza=demo-alt
P00   INFO: stanza-create for stanza 'demo-alt' on repo1

P00   INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=392-ff851d84 --log-level-console=info --log-level-file=detail --no-log-timestamp --repo1-host=repository

P00   INFO: check stanza 'demo-alt'

P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 000000010000000000000001 successfully archived to '/var/lib/pgbackrest/archive/demo-alt/17-1/0000000100000000/000000010000000000000001-2e1aa7ba9df559c7d086abb2822a205a3877abee.gz' on repo1

P00   INFO: check command end: completed successfully

Run check on the repository host to check all stanzas.

repository ⇒ Check the configuration for all stanzas

sudo -u pgbackrest pgbackrest --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=1256-3298101d --log-level-console=info --no-log-timestamp --repo1-path=/var/lib/pgbackrest

P00   INFO: check stanza 'demo'

P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 000000070000000000000027 successfully archived to '/var/lib/pgbackrest/archive/demo/17-1/0000000700000000/000000070000000000000027-7ed0b35e117b8c41cd74c613408ad2908ae67ffd.gz' on repo1
P00   INFO: check stanza 'demo-alt'

P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 000000010000000000000002 successfully archived to '/var/lib/pgbackrest/archive/demo-alt/17-1/0000000100000000/000000010000000000000002-9a51918560e4a3eb1eb9878b3842f95520ee13a0.gz' on repo1

P00   INFO: check command end: completed successfully

Asynchronous Archiving

Enable archive-async for asynchronous archive-push and archive-get.

Create a spool path for transient data. Each command uses it differently, as described in the following sections.

pg-primary ⇒ Create the spool directory

sudo mkdir -p -m 750 /var/spool/pgbackrest
sudo chown postgres:postgres /var/spool/pgbackrest

pg-standby ⇒ Create the spool directory

sudo mkdir -p -m 750 /var/spool/pgbackrest
sudo chown postgres:postgres /var/spool/pgbackrest

Configure the spool path and enable asynchronous archiving. This reduces remote-storage connections. Set process-max for parallel operations and further performance improvements. Keep it low enough to preserve normal database performance.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure the spool path and asynchronous archiving

[demo]
pg1-path=/var/lib/postgresql/17/demo
[global]
archive-async=y
log-level-file=detail
repo1-host=repository
spool-path=/var/spool/pgbackrest
[global:archive-get]
process-max=2
[global:archive-push]
process-max=2

pg-standby:/etc/pgbackrest/pgbackrest.conf ⇒ Configure the spool path and asynchronous archiving

[demo]
pg1-path=/var/lib/postgresql/17/demo
recovery-option=primary_conninfo=host=172.17.0.6 port=5432 user=replicator
[global]
archive-async=y
log-level-file=detail
repo1-host=repository
spool-path=/var/spool/pgbackrest
[global:archive-get]
process-max=2
[global:archive-push]
process-max=2

NOTE:

Set process-max in command-specific sections so it does not affect backup or restore. You can give archive-push and archive-get different values.

For this demonstration, interrupt streaming replication so PostgreSQL must fetch WAL through restore_command.

pg-primary ⇒ Break streaming replication by changing the replication password

sudo -u postgres psql -c "alter user replicator password 'bogus'"
ALTER ROLE

pg-standby ⇒ Restart standby to break connection

sudo pg_ctlcluster 17 demo restart

Archive Push

Asynchronous archive-push transfers WAL archiving to separate processes to improve throughput. It finds ready segments beyond the one PostgreSQL currently requests through archive_command. It copies WAL directly from pg_xlog/pg_wal to the archive. The archive_command returns success only after the requested segment is safely stored.

The spool path contains current WAL archive status. Status files are usually empty and use little I/O and space, at most a few MB. pgBackRest can recreate all this information. You do not need to preserve the directory when moving the cluster to new hardware.

IMPORTANT:

The original asynchronous implementation copied WAL to the spool directory before compression and transfer. The newer implementation reads WAL directly from pg_xlog. If you used asynchronous archiving in v1.12 or earlier, read the v1.13 release notes carefully before upgrading.

Monitor asynchronous activity in [stanza]-archive-push-async.log. To test it, push several WAL segments quickly.

pg-primary ⇒ Test parallel asynchronous archiving

sudo -u postgres psql -c " \
       select pg_create_restore_point('test async push'); select pg_switch_wal(); \
       select pg_create_restore_point('test async push'); select pg_switch_wal(); \
       select pg_create_restore_point('test async push'); select pg_switch_wal(); \
       select pg_create_restore_point('test async push'); select pg_switch_wal(); \
       select pg_create_restore_point('test async push'); select pg_switch_wal();"

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=2592-53cb1c02 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --repo1-host=repository --stanza=demo
P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 00000007000000000000002D successfully archived to '/var/lib/pgbackrest/archive/demo/17-1/0000000700000000/00000007000000000000002D-064d3920b7f65a78eadb35930be56d0b1aeb59fb.gz' on repo1

P00   INFO: check command end: completed successfully

The log now shows parallel, asynchronous activity.

pg-primary ⇒ Check results in the log

sudo -u postgres cat /var/log/pgbackrest/demo-archive-push-async.log
-------------------PROCESS START-------------------
P00   INFO: archive-push:async command begin 2.59.2: [/var/lib/postgresql/17/demo/pg_wal] --archive-async --exec-id=2579-4f897cce --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo

P00   INFO: push 1 WAL file(s) to archive: 000000070000000000000028
P01 DETAIL: pushed WAL file '000000070000000000000028' to the archive

P00   INFO: archive-push:async command end: completed successfully

-------------------PROCESS START-------------------
P00   INFO: archive-push:async command begin 2.59.2: [/var/lib/postgresql/17/demo/pg_wal] --archive-async --exec-id=2596-db8c73d8 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo

P00   INFO: push 5 WAL file(s) to archive: 000000070000000000000029...00000007000000000000002D
P01 DETAIL: pushed WAL file '000000070000000000000029' to the archive
P02 DETAIL: pushed WAL file '00000007000000000000002A' to the archive
P02 DETAIL: pushed WAL file '00000007000000000000002C' to the archive
P01 DETAIL: pushed WAL file '00000007000000000000002B' to the archive
P02 DETAIL: pushed WAL file '00000007000000000000002D' to the archive

P00   INFO: archive-push:async command end: completed successfully

Archive Get

Asynchronous archive-get keeps a local WAL queue to improve throughput. If a requested segment is absent, it fetches that segment and enough consecutive segments to fill the queue. archive-get-queue-max controls maximum size. When the queue falls below half full, pgBackRest fetches more WAL to refill it.

Asynchronous operation helps most with high WAL volumes or high-latency repository connections, such as S3 and other object stores. For high latency, consider increasing process-max.

Monitor asynchronous activity in [stanza]-archive-get-async.log.

pg-standby ⇒ Check results in the log

sudo -u postgres cat /var/log/pgbackrest/demo-archive-get-async.log
-------------------PROCESS START-------------------
P00   INFO: archive-get:async command begin 2.59.2: [000000070000000000000024, 000000070000000000000025, 000000070000000000000026, 000000070000000000000027, 000000070000000000000028, 000000070000000000000029, 00000007000000000000002A, 00000007000000000000002B] --archive-async --exec-id=736-1978b097 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00   INFO: get 8 WAL file(s) from archive: 000000070000000000000024...00000007000000000000002B
P01 DETAIL: found 000000070000000000000024 in the repo1: 17-1 archive

P02 DETAIL: found 000000070000000000000025 in the repo1: 17-1 archive
P01 DETAIL: found 000000070000000000000026 in the repo1: 17-1 archive
P02 DETAIL: found 000000070000000000000027 in the repo1: 17-1 archive

P00 DETAIL: unable to find 000000070000000000000028 in the archive
P00   INFO: archive-get:async command end: completed successfully
       [filtered 14 lines of output]
P00   INFO: archive-get:async command begin 2.59.2: [000000070000000000000028, 000000070000000000000029, 00000007000000000000002A, 00000007000000000000002B, 00000007000000000000002C, 00000007000000000000002D, 00000007000000000000002E, 00000007000000000000002F] --archive-async --exec-id=789-38affa51 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/postgresql/17/demo --process-max=2 --repo1-host=repository --spool-path=/var/spool/pgbackrest --stanza=demo
P00   INFO: get 8 WAL file(s) from archive: 000000070000000000000028...00000007000000000000002F

P02 DETAIL: found 000000070000000000000029 in the repo1: 17-1 archive
P01 DETAIL: found 000000070000000000000028 in the repo1: 17-1 archive
P02 DETAIL: found 00000007000000000000002A in the repo1: 17-1 archive
P01 DETAIL: found 00000007000000000000002B in the repo1: 17-1 archive
P02 DETAIL: found 00000007000000000000002C in the repo1: 17-1 archive
P01 DETAIL: found 00000007000000000000002D in the repo1: 17-1 archive

P00 DETAIL: unable to find 00000007000000000000002E in the archive
P00   INFO: archive-get:async command end: completed successfully
       [filtered 11 lines of output]

pg-primary ⇒ Fix streaming replication by changing the replication password

sudo -u postgres psql -c "alter user replicator password 'jw8s0F4'"
ALTER ROLE

Backup from a Standby

pgBackRest can back up from a standby instead of the primary. Configure pg-standby and enable backup-standby. If several standbys are configured, it uses the first running standby found.

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pg2-host/pg2-host-user and pg2-path

[demo]
pg1-host=pg-primary
pg1-path=/var/lib/postgresql/17/demo
pg2-host=pg-standby
pg2-path=/var/lib/postgresql/17/demo
[demo-alt]
pg1-host=pg-alt
pg1-path=/var/lib/postgresql/17/demo
[global]
backup-standby=y
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y

Backup requires both the primary and standby databases. Most files come from the standby to reduce primary load. Configure hosts in any order. pgBackRest detects their roles automatically.

repository ⇒ Backup the demo cluster from pg2

sudo -u pgbackrest pgbackrest --stanza=demo --log-level-console=detail backup
       [filtered 2 lines of output]
P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 00000007000000000000002F, lsn = 0/2F000028
P00   INFO: wait for replay on the standby to reach 0/2F000028
P00   INFO: replay on the standby reached 0/2F000028
P00   INFO: check archive for prior segment 00000007000000000000002E
P01 DETAIL: backup file pg-primary:/var/lib/postgresql/17/demo/global/pg_control (8KB, 0.53%) checksum 7d84baa1f0b16cc8652b16c41ef075f5df25d016
P01 DETAIL: match file from prior backup pg-primary:/var/lib/postgresql/17/demo/pg_logical/replorigin_checkpoint (8B, 0.53%) checksum 347fc8f2df71bd4436e38bd1516ccd7ea0d46532
P02 DETAIL: backup file pg-standby:/var/lib/postgresql/17/demo/base/5/1249 (448KB, 30.16%) checksum 3b6f5ca3b766aa5972894958f6b2f4d0d98f0228
       [filtered 1278 lines of output]

This incremental backup copies most files from pg-standby and only a few from pg-primary.

A standby backup is identical to a primary backup. pgBackRest starts and stops the backup on pg-primary. It copies replicated files from pg-standby and the remaining files from pg-primary. Thus, the backup includes primary logs and statistics.


Upgrading PostgreSQL

Immediately after a PostgreSQL major version upgrade, update pg-path in all pgBackRest configurations to the new database location. Then run stanza-upgrade. It upgrades the stanza in every repository configured on the host. If the database is offline, use --no-online.

These steps outline a primary and standby upgrade to demonstrate pgBackRest reconfiguration. They are not a complete PostgreSQL upgrade guide. Take a backup before upgrading.

pg-primary ⇒ Stop old cluster

sudo pg_ctlcluster 17 demo stop

Stop the old standby cluster. You will restore it from the upgraded cluster.

pg-standby ⇒ Stop old cluster

sudo pg_ctlcluster 17 demo stop

Create the new cluster and upgrade it.

pg-primary ⇒ Create new cluster and perform the upgrade

sudo -u postgres /usr/lib/postgresql/18/bin/initdb \
       -D /var/lib/postgresql/18/demo -k -A peer

sudo pg_createcluster 18 demo
sudo -u postgres sh -c 'cd /var/lib/postgresql && \
       /usr/lib/postgresql/18/bin/pg_upgrade \
       --old-bindir=/usr/lib/postgresql/17/bin \
       --new-bindir=/usr/lib/postgresql/18/bin \
       --old-datadir=/var/lib/postgresql/17/demo \
       --new-datadir=/var/lib/postgresql/18/demo \
       --old-options=" -c config_file=/etc/postgresql/17/demo/postgresql.conf" \
       --new-options=" -c config_file=/etc/postgresql/18/demo/postgresql.conf"'
       [filtered 44 lines of output]
Checking for extension updates                                ok

Upgrade Complete

----------------
Some statistics are not transferred by pg_upgrade.
       [filtered 4 lines of output]

Configure the new cluster settings and port.

pg-primary:/etc/postgresql/18/demo/postgresql.conf ⇒ Configure PostgreSQL

archive_command = 'pgbackrest --stanza=demo archive-push %p'
archive_mode = on

Update pgBackRest configuration on every system to use the new cluster.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Upgrade the pg1-path

[demo]
pg1-path=/var/lib/postgresql/18/demo
[global]
archive-async=y
log-level-file=detail
repo1-host=repository
spool-path=/var/spool/pgbackrest
[global:archive-get]
process-max=2
[global:archive-push]
process-max=2

pg-standby:/etc/pgbackrest/pgbackrest.conf ⇒ Upgrade the pg-path

[demo]
pg1-path=/var/lib/postgresql/18/demo
recovery-option=primary_conninfo=host=172.17.0.6 port=5432 user=replicator
[global]
archive-async=y
log-level-file=detail
repo1-host=repository
spool-path=/var/spool/pgbackrest
[global:archive-get]
process-max=2
[global:archive-push]
process-max=2

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Upgrade pg1-path and pg2-path, disable backup from standby

[demo]
pg1-host=pg-primary
pg1-path=/var/lib/postgresql/18/demo
pg2-host=pg-standby
pg2-path=/var/lib/postgresql/18/demo
[demo-alt]
pg1-host=pg-alt
pg1-path=/var/lib/postgresql/17/demo
[global]
backup-standby=n
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y

pg-primary ⇒ Copy hba configuration

sudo cp /etc/postgresql/17/demo/pg_hba.conf \
       /etc/postgresql/18/demo/pg_hba.conf

Before starting the new cluster, run stanza-upgrade.

pg-primary ⇒ Upgrade the stanza

sudo -u postgres pgbackrest --stanza=demo --no-online \
       --log-level-console=info stanza-upgrade
P00   INFO: stanza-upgrade command begin 2.59.2: --exec-id=3018-a8daf62d --log-level-console=info --log-level-file=detail --no-log-timestamp --no-online --pg1-path=/var/lib/postgresql/18/demo --repo1-host=repository --stanza=demo
P00   INFO: stanza-upgrade for stanza 'demo' on repo1

P00   INFO: stanza-upgrade command end: completed successfully

Start the new cluster and verify the installation.

pg-primary ⇒ Start new cluster

sudo pg_ctlcluster 18 demo start

Test configuration with check.

pg-primary ⇒ Check configuration

sudo pg_lsclusters
sudo -u postgres pgbackrest --stanza=demo check

Remove the old cluster.

pg-primary ⇒ Remove old cluster

sudo pg_dropcluster 17 demo

Install the new PostgreSQL binaries on the standby and create the cluster.

pg-standby ⇒ Remove old cluster and create the new cluster

sudo pg_dropcluster 17 demo
sudo pg_createcluster 18 demo

Run check on the repository host. The standby is stopped, so expect a warning. This verifies that the repository knows about the standby and has correct primary configuration.

repository ⇒ Check configuration

sudo -u pgbackrest pgbackrest --stanza=demo check
P00   WARN: unable to check pg2: [DbConnectError] raised from remote-0 ssh protocol on 'pg-standby': unable to connect to 'dbname='postgres' port=5432': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
                Is the server running locally and accepting connections on that socket?

Take a full backup of the new cluster, then restore the standby from it. Requests for incr or diff automatically change to full.

repository ⇒ Run a full backup

sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup

pg-standby ⇒ Restore the demo standby cluster

sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore

pg-standby ⇒ Start PostgreSQL and check the pgBackRest configuration

sudo pg_ctlcluster 18 demo start
sudo -u postgres pgbackrest --stanza=demo check

After restoring the standby, enable standby backups again.

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Re-enable backup from standby

[demo]
pg1-host=pg-primary
pg1-path=/var/lib/postgresql/18/demo
pg2-host=pg-standby
pg2-path=/var/lib/postgresql/18/demo
[demo-alt]
pg1-host=pg-alt
pg1-path=/var/lib/postgresql/17/demo
[global]
backup-standby=y
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y

3 - User Guide (RHEL)

Step-by-step pgBackRest setup and usage guide for RHEL, Rocky, and AlmaLinux systems.

Source: pgBackRest 2.59.2 user guide.


Introduction

Follow this guide in order the first time. Each section depends on earlier sections. For example, Restore requires the configuration from Quick Start. After pgBackRest is running, you can use sections independently.

These examples use RHEL and PostgreSQL 14. You can adapt them to other Unix distributions and PostgreSQL versions. Only commands to create, start, stop, and drop clusters depend on the OS. pgBackRest commands are the same across Unix systems, although the executable location can differ. PostgreSQL versions can differ in paths, file names, and settings; some examples show these differences.

Configuration information and documentation for PostgreSQL can be found in the PostgreSQL Manual.

The documentation build runs each command on a virtual machine from the XML source. This verifies that commands work in the specified order. Relevant output appears below each command. Other output is omitted to keep the instructions clear.

Run commands as an unprivileged user with sudo access to root and postgres. Alternatively, run each command directly as its specified user and remove sudo.


Concepts

The following definitions apply to pgBackRest, PostgreSQL, and this guide.

Backup

A backup is a consistent copy of a database cluster. Restore it to recover from hardware failure, perform Point-In-Time Recovery, or create a standby.

Full Backup: Copy all database cluster contents. The first cluster backup is always full. pgBackRest can restore it directly without files from another backup to achieve consistency.

Differential Backup: Copy files changed since the last full backup. Restore combines those files with unchanged files from that full backup. This uses less disk space than a full backup. Both the differential and its full backup must be valid for a restore.

Incremental Backup: Copy files changed since the last backup, whether full, differential, or incremental. Incremental backups are usually much smaller than full or differential backups. A restore requires valid versions of every backup in its dependency chain. This includes all incrementals back to the preceding differential, that differential, and its full backup. If no differential exists, it includes all incrementals back to the full backup and that full backup itself.

Restore

A restore copies backup files to a system where PostgreSQL can start them as a live cluster. It requires backup files and one or more WAL segments.

Write Ahead Log (WAL)

PostgreSQL uses WAL to prevent loss of committed changes. It writes transactions sequentially to WAL and considers them committed when those writes reach disk. A background process then writes the changes to the main database files, also called the heap. After a crash, WAL replay restores database consistency.

WAL is conceptually infinite but consists of individual 16MB segment files. A segment name has the form 0000000100000A1E000000FE. The first 8 hexadecimal digits identify the timeline. The next 16 identify the logical sequence number (LSN).

Encryption

Encryption converts data into a form that requires the correct password, also called a passphrase, to read.

pgBackRest encrypts the repository with a user-supplied password to prevent unauthorized access to its stored data.


Upgrading pgBackRest

Upgrading pgBackRest from v2.x to v2.y

To upgrade from v2.x to v2.y, most installations only need the new binaries. The repository format is unchanged. You can also downgrade unless you have used features that the older version does not support.

IMPORTANT:

Local and remote pgBackRest versions must match exactly. Upgrade them together. If versions differ, WAL archiving and backups fail until they match. The error is: [ProtocolError] expected value '2.x' for greeting key 'version' but got '2.y'.


Build

Prefer package installation to a source build. See Installation for package information.

Build from source on a separate build host. Production hosts generally should not have the required build tools. pgBackRest is one executable, which you can copy to other hosts after the build.

build ⇒ Download version 2.59.2 of pgBackRest to /build path

mkdir -p /build
curl -fsSL \
       https://github.com/pgbackrest/pgbackrest/releases/download/release%2F2.59.2/pgbackrest-2.59.2.tar.gz | \
       tar zx -C /build

build ⇒ Install build dependencies

sudo yum install meson gcc postgresql14-devel openssl-devel libxml2-devel \
       lz4-devel libzstd-devel bzip2-devel libssh2-devel systemd-devel

build ⇒ Configure and compile pgBackRest

meson setup /build/pgbackrest /build/pgbackrest-2.59.2
ninja -C /build/pgbackrest

build ⇒ Optionally run smoke tests to verify pgBackRest was built correctly

meson test -C /build/pgbackrest --suite smoke
ninja: Entering directory `/build/pgbackrest'
ninja: no work to do.
1/1 smoke OK               11.37s
Ok:                 1
       [filtered 6 lines of output]

Installation

Create a host named pg-primary for the demo cluster and pgBackRest examples.

Prefer package installation to a source build. Packages usually perform the remaining steps in this section. If a package omits a directory or sets incorrect permissions, create the directory or correct its permissions manually.

RHEL packages for pgBackRest are available at yum.postgresql.org.

If your distribution or version has no package, build from source and follow these manual installation steps.

pg-primary ⇒ Install dependencies

sudo yum install postgresql-libs libssh2

pg-primary ⇒ Copy pgBackRest binary from build host

sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest

pgBackRest requires log and configuration directories and a configuration file.

pg-primary ⇒ Create pgBackRest configuration file and directories

sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf

Check the installation. Running pgBackRest on the command line reports an error if a dependency is missing.

pg-primary ⇒ Make sure the installation worked

sudo -u postgres pgbackrest
pgBackRest 2.59.2 - General help

Usage:
    pgbackrest [options] [command]

Commands:
    annotate        add or modify backup annotation
    archive-get     get a WAL segment from the archive
    archive-push    push a WAL segment to the archive
    backup          backup a database cluster
    check           check the configuration
    expire          expire backups that exceed retention
    help            get help
    info            retrieve information about backups
    repo-get        get a file from a repository
    repo-ls         list files in a repository
    restore         restore a database cluster
    server          pgBackRest server
    server-ping     ping pgBackRest server
    stanza-create   create the required stanza data
    stanza-delete   delete a stanza
    stanza-upgrade  upgrade a stanza
    start           allow pgBackRest processes to run
    stop            stop pgBackRest processes from running
    verify          verify contents of a repository
    version         get version

Use 'pgbackrest help [command]' for more information.

Quick Start

Quick Start covers basic pgBackRest and PostgreSQL configuration. It introduces backup, restore, and info.

Setup Demo Cluster

The demo cluster is optional but strongly recommended, especially for new users. Examples use this cluster on the default port, 5432. Start it in a later section after configuration is complete.

pg-primary ⇒ Create the demo cluster

sudo -u postgres /usr/pgsql-14/bin/initdb \
       -D /var/lib/pgsql/14/data -k -A peer

RHEL log filenames include the day of the week by default. Set log_filename to a constant value to simplify these examples.

pg-primary:/var/lib/pgsql/14/data/postgresql.conf ⇒ Set log_filename

log_filename = 'postgresql.log'

Configure Cluster Stanza

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

Use demo as the stanza name because it describes the cluster purpose.

pgBackRest needs the PostgreSQL base data directory. PostgreSQL can report it, but is unavailable during recovery. Set pg-path to exactly the data_directory value reported by PostgreSQL. Each backup compares these paths and fails if they differ.

RHEL stores clusters in /var/lib/pgsql/[version]/data by default. Use this location to identify the data directory.

When you create /etc/pgbackrest/pgbackrest.conf, grant read access to the database owner, usually postgres.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure the PostgreSQL cluster data directory

[demo]
pg1-path=/var/lib/pgsql/14/data

pgBackRest configuration files use a Windows INI-like format. Bracketed section names contain key/value pairs. Lines starting with # are comments; comments after a value on the same line are unsupported. Quoting is unsupported. pgBackRest trims whitespace from keys and values. Repeated sections are merged.

Configuration loading depends on these options:

  • Default config and config-include-path: load the default file if present. Append *.conf files from the default include path if present.
  • Explicit config: load only the specified file, which must exist.
  • Explicit config-include-path: load its *.conf files; the path must exist. Also load the default configuration file if present. Add --no-config to load only include-path files.
  • Explicit config and config-include-path: load the specified file and append *.conf files from the specified include path. The files must exist.
  • Explicit config-path: override the base path for the default configuration file and include path. Explicit config or config-include-path settings take precedence.

pgBackRest combines the files as one file, but each file must be valid independently. Each file must declare sections for its key/value pairs. File order does not determine precedence; sections do. The order from highest to lowest precedence is:

  • [stanza:command]
  • [stanza]
  • [global:command]
  • [global]

NOTE:

--config, --config-include-path and --config-path are command-line only options.

Environment variables can also configure pgBackRest, as shown below. They apply to commands such as backup, restore, and archive-push.

pg-primary ⇒ Configure log-path using the environment

sudo -u postgres bash -c ' \
       export PGBACKREST_LOG_PATH=/path/set/by/env && \
       pgbackrest --log-level-console=error help backup log-path'
pgBackRest 2.59.2 - 'backup' command - 'log-path' option help

Path where log files are stored.

The log path provides a location for pgBackRest to store log files. Note that
if log-level-file=off then no log path is required.
current: /path/set/by/env

default: /var/log/pgbackrest

Create the Repository

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

This example stores the repository on the PostgreSQL host. This is the simplest configuration. It is useful when conventional backup software also backs up that host.

pg-primary ⇒ Create the pgBackRest repository

sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown postgres:postgres /var/lib/pgbackrest

Configure the repository path so pgBackRest can find it.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure the pgBackRest repository path

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-path=/var/lib/pgbackrest

You can configure multiple repositories. See Multiple Repositories.

Configure Archiving

Enable WAL archiving before backing up a running PostgreSQL cluster. PostgreSQL uses %p to specify the WAL segment location. A backup creates at least one WAL segment, even without explicit cluster writes.

pg-primary:/var/lib/pgsql/14/data/postgresql.conf ⇒ Configure archive settings

archive_command = 'pgbackrest --stanza=demo archive-push %p'
archive_mode = on
log_filename = 'postgresql.log'

After these changes, restart the PostgreSQL cluster before taking a backup.

pg-primary ⇒ Restart the demo cluster

sudo systemctl restart postgresql-14.service

Keep hot_standby enabled, which is the default, on every cluster. Any cluster might later become a standby, including a former primary after failover. A standby requires this setting to accept read-only connections.

If a WAL segment needs more than the default 60 seconds to reach the repository, increase pgBackRest archive-timeout. This differs from PostgreSQL archive_timeout, which forces a WAL segment switch during long inactive periods. See PostgreSQL Write Ahead Log for archive_timeout details.

Set command-specific options for archive-push. For example, a lower compression level can speed archiving without changing backup compression.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Config archive-push to use a lower compression level

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-path=/var/lib/pgbackrest
[global:archive-push]
compress-level=3

Use command-specific configuration for any command. You can also limit it to one stanza, such as demo:archive-push.

Configure Retention

pgBackRest expires backups based on retention options.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure retention to 2 full backups

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
[global:archive-push]
compress-level=3

See Retention for more information.

Configure Repository Encryption

Set a repository cipher type and key to demonstrate encryption. Encryption always occurs on the client, even when storage such as S3 supports encryption.

Use a long, random passphrase for the cipher key. Generate one with openssl rand -base64 48.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pgBackRest repository encryption

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
[global:archive-push]
compress-level=3

NOTE:

The example puts encryption settings in [global] so info can read all stanzas. Without stanza, info reads encryption settings only from [global]. For stanza-specific encryption, supply stanza to read the encrypted stanza.

After configuring the repository and creating and checking the stanza, you cannot change its encryption settings.

Create the Stanza

Run stanza-create to initialize the stanza. Then run check to verify archive and backup configuration.

pg-primary ⇒ Create the stanza and check the configuration

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00   INFO: stanza-create command begin 2.59.2: --exec-id=1200-46a7e87f --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo
P00   INFO: stanza-create for stanza 'demo' on repo1

P00   INFO: stanza-create command end: completed successfully

Check the Configuration

The check command validates pgBackRest and archive_command configuration for the specified stanza. It checks backup and archive settings for all repositories and databases configured on the current host. It detects configuration errors, especially archive errors that leave backups incomplete because required WAL segments never reached the archive. Run it on the PostgreSQL or repository host. You can also run it on a standby, but then it checks only repository configuration. A standby cannot execute pg_switch_xlog()/pg_switch_wal().

The command calls pg_create_restore_point('pgBackRest Archive Check') and pg_switch_xlog()/pg_switch_wal() to force PostgreSQL to archive a WAL segment.

pg-primary ⇒ Check the configuration

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=1233-8a8db696 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo
P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 000000010000000000000001 successfully archived to '/var/lib/pgbackrest/archive/demo/14-1/0000000100000000/000000010000000000000001-d0ad328a3c9ff2237a7030a37d1f6910a4ed952f.gz' on repo1

P00   INFO: check command end: completed successfully

Performance Tuning

Some performance options are disabled by default to preserve repository compatibility. Enable the following options for new repositories. You can also enable them for existing repositories, but older pgBackRest versions might then be unable to read them. Compatibility depends on the feature introduction version shown below.

  • compress-type selects compression for backup and archive-push. The default is gz (Gzip). Prefer zst (Zstandard) for much faster processing with similar compression. Support started in v2.27. See Compress Type.
  • repo-bundle combines small files to save space and speed backup and restore, especially on object stores such as S3. It was introduced in v2.39. See File Bundling.
  • repo-block stores changed parts of files during diff/incr backup, which saves space and speeds backups. It was introduced in v2.46, but use at least v2.52.1. See Block Incremental.

Other performance options need additional configuration, or use safe defaults that are not optimal. These options are available in every v2 release.

  • process-max controls the number of processes. Its default, 1, is rarely suitable. Each command uses it differently; see the command documentation.
  • archive-async archives WAL in batches for much higher speed. It is disabled by default because it requires a spool path. See Asynchronous Archiving.
  • backup-standby reduces primary load by backing up from a standby. It is disabled by default because it needs extra configuration and at least one standby. See Backup from a Standby.

Perform a Backup

By default, backups wait for the next regular checkpoint. PostgreSQL checkpoint_timeout and checkpoint_segments settings can make this a long wait. Usually, set start-fast=y to force a checkpoint and start immediately. For a daily backup, one extra checkpoint should have little performance impact. On very busy clusters, use --start-fast on the command line only when needed.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure backup fast start

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

Run pgBackRest backup to back up the PostgreSQL cluster.

pg-primary ⇒ Backup the demo cluster

sudo -u postgres pgbackrest --stanza=demo \
       --log-level-console=info backup
P00   INFO: backup command begin 2.59.2: --exec-id=1327-70764233 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo --start-fast

P00   WARN: no prior backup exists, incr backup has been changed to full

P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 000000010000000000000002, lsn = 0/2000028
       [filtered 3 lines of output]
P00   INFO: check archive for segment(s) 000000010000000000000002:000000010000000000000003
P00   INFO: new backup label = 20260927-100955F

P00   INFO: full backup size = 25.2MB, file total = 951

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=1327-70764233 --log-level-console=info --no-log-timestamp --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo

By default, pgBackRest attempts an incremental backup. An incremental requires a full backup. Because none existed, pgBackRest created a full backup.

Use type to select a full or differential backup.

pg-primary ⇒ Differential backup of the demo cluster

sudo -u postgres pgbackrest --stanza=demo --type=diff \
       --log-level-console=info backup
       [filtered 7 lines of output]
P00   INFO: check archive for segment(s) 000000010000000000000004:000000010000000000000005
P00   INFO: new backup label = 20260927-100955F_20260927-100957D

P00   INFO: diff backup size = 9.2KB, file total = 951

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=1398-685541bc --log-level-console=info --no-log-timestamp --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-full=2 --stanza=demo

No warning appeared because a full backup already existed. Incrementals can depend on a full or differential backup. Differentials must depend on a full backup. To create a full backup, run backup with --type=full.

During an online backup, pgBackRest waits for the archive to receive all WAL segments necessary for consistency. The archive-timeout default is 60 seconds. Increase it if an individual segment takes longer to archive.

Schedule a Backup

Backups can be scheduled with utilities such as cron.

The example schedules full backups at 6:30 AM each Sunday. It schedules differential backups at 6:30 AM Monday through Saturday. If installed midweek, the first differential job creates a full backup. The next day, it creates a differential.

#m h   dom mon dow   command
30 06  *   *   0     pgbackrest --type=full --stanza=demo backup
30 06  *   *   1-6   pgbackrest --type=diff --stanza=demo backup

After scheduling backups, configure regular expiration. See Retention.

Backup Information

Use the info command to get information about backups.

pg-primary ⇒ Get info for the demo cluster

sudo -u postgres pgbackrest info
stanza: demo
    status: ok
    cipher: aes-256-cbc

    db (current)
        wal archive min/max (14): 000000010000000000000001/000000010000000000000005
        full backup: 20260927-100955F
            timestamp start/stop: 2026-09-27 10:09:55+00 / 2026-09-27 10:09:57+00
            wal start/stop: 000000010000000000000002 / 000000010000000000000003
            database size: 25.2MB, database backup size: 25.2MB
            repo1: backup set size: 3.2MB, backup size: 3.2MB
        diff backup: 20260927-100955F_20260927-100957D
            timestamp start/stop: 2026-09-27 10:09:57+00 / 2026-09-27 10:09:59+00
            wal start/stop: 000000010000000000000004 / 000000010000000000000005
            database size: 25.2MB, database backup size: 9.2KB
            repo1: backup set size: 3.2MB, backup size: 880B
            backup reference total: 1 full

The info command reports on one stanza or all stanzas. By default, text output summarizes backups for the requested stanzas. The text format can change in any release.

For machine-readable output, use --output=json. JSON includes much more information than text output. Its format stays stable unless a bug requires a change.

Use --detail-level=progress to show only progress and reduce execution time. This skips all checks except stanza availability.

Each stanza has a separate section. Use --stanza to show only one. The status field indicates stanza health: ok means pgBackRest operates normally. With multiple repositories, mixed means at least one repository has an unhealthy stanza; output then gives the status per repository. An unknown repository error uses the code other and includes full error details.

The wal archive min/max field shows the minimum and maximum archived WAL. With multiple repositories, it covers all repositories unless you set --repo. Archive retention policies or other causes can leave gaps in this range.

The backup/expire running and/or restore running messages appear beside status when those commands run on the host. Text output also shows progress per repository. JSON output includes a repo array.

Backups appear from oldest to newest. The oldest is always a full backup, with an F at the end of its label. The newest can be full, differential (label ends with D), or incremental (label ends with I).

The timestamp start/stop field shows when the backup ran. Use timestamp stop to select a backup for Point-In-Time Recovery. See Point-In-Time Recovery.

The wal start/stop field shows the WAL range necessary for database consistency after a restore. The backup command checks that the archive contains this range before it completes.

The database size field shows the full, uncompressed database size. The database backup size field shows the database data actually backed up. These values match for full backups.

The repo field identifies the repository that contains the backup. The backup set size includes files in this backup and referenced backups needed for a restore. The backup size includes only files in this backup. These sizes match for full backups. When pgBackRest compression is enabled, repository sizes reflect compressed files.

The backup reference total summarizes other backups needed to restore this backup. Use --set for the complete reference list.

Restore a Backup

Backups protect against failures, including hardware failure and data corruption. For this example, simulate corruption by removing an essential cluster file.

pg-primary ⇒ Stop the demo cluster and delete the pg_control file

sudo systemctl stop postgresql-14.service
sudo -u postgres rm /var/lib/pgsql/14/data/global/pg_control

Starting the cluster without this file produces an error.

pg-primary ⇒ Attempt to start the corrupted demo cluster

sudo systemctl start postgresql-14.service
sudo systemctl status postgresql-14.service
postgresql-14.service - PostgreSQL 14 database server
    Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service, disabled)

    Active: failed (failed)

Run pgBackRest restore to restore the PostgreSQL cluster. First stop the cluster, which is already stopped in this example. Remove all files from its data directory.

pg-primary ⇒ Remove old files from demo cluster

sudo -u postgres find /var/lib/pgsql/14/data -mindepth 1 -delete

pg-primary ⇒ Restore the demo cluster and start PostgreSQL

sudo -u postgres pgbackrest --stanza=demo restore
sudo systemctl start postgresql-14.service

The cluster started because the restore replaced the missing pg_control file.

See Restore for more information about restore.


Monitoring

Monitor production systems. You can integrate pgBackRest with many monitoring tools.

pgBackRest JSON output includes all backups for each stanza and WAL archive information.

In PostgreSQL

Use PostgreSQL COPY to load pgBackRest information into a table. This example puts that logic in a function for real-time queries.

pg-primary ⇒ Load pgBackRest info function for PostgreSQL

sudo -u postgres cat \
       /var/lib/pgsql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql
-- An example of monitoring pgBackRest from within PostgreSQL
--
-- Use copy to export data from the pgBackRest info command into the jsonb
-- type so it can be queried directly by PostgreSQL.

-- Create monitor schema
create schema monitor;

-- Get pgBackRest info in JSON format
create function monitor.pgbackrest_info()
    returns jsonb AS $$
declare
    data jsonb;
begin
    -- Create a temp table to hold the JSON data
    create temp table temp_pgbackrest_data (data text);

    -- Copy data into the table directly from the pgBackRest info command
    copy temp_pgbackrest_data (data)
        from program
            'pgbackrest --output=json info' (format text);

    select replace(temp_pgbackrest_data.data, E'\n', '\n')::jsonb
      into data
      from temp_pgbackrest_data;

    drop table temp_pgbackrest_data;

    return data;
end $$ language plpgsql;
sudo -u postgres psql -f \
       /var/lib/pgsql/pgbackrest/doc/example/pgsql-pgbackrest-info.sql

Use monitor.pgbackrest_info() to find a stanza’s last successful backup time and archived WAL.

pg-primary ⇒ Query last successful backup time and archived WAL

sudo -u postgres cat \
       /var/lib/pgsql/pgbackrest/doc/example/pgsql-pgbackrest-query.sql
-- Get last successful backup for each stanza
--
-- Requires the monitor.pgbackrest_info function.
with stanza as
(
    select data->'name' as name,
           data->'backup'->(
               jsonb_array_length(data->'backup') - 1) as last_backup,
           data->'archive'->(
               jsonb_array_length(data->'archive') - 1) as current_archive
      from jsonb_array_elements(monitor.pgbackrest_info()) as data
)
select name,
       to_timestamp(
           (last_backup->'timestamp'->>'stop')::numeric) as last_successful_backup,
       current_archive->>'max' as last_archived_wal
  from stanza;
sudo -u postgres psql -f \
       /var/lib/pgsql/pgbackrest/doc/example/pgsql-pgbackrest-query.sql
  name  | last_successful_backup |    last_archived_wal
--------+------------------------+--------------------------
 "demo" | 2026-09-27 10:09:59+00 | 000000010000000000000005
(1 row)

Backup

With multiple repositories, pgBackRest backs up to the highest priority repository, such as repo1. Use --repo to select another repository.

pgBackRest has no built-in scheduler. Use cron or another scheduler to run it.

See Perform a Backup for more details and examples.

File Bundling

File bundles reduce backup time and repository space. Benefits are greatest on object stores, such as S3, and filesystems with large blocks. Object stores have higher per-file creation costs. Very small files can cost as much to store as larger files.

Enable file bundles with repo-bundle.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-bundle

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

A full backup without bundles has more than 1000 files in its backup path. Bundles substantially reduce this count. Zero-length files then have only manifest entries. Without bundles, each zero-length file is stored separately.

pg-primary ⇒ Perform a full backup

sudo -u postgres pgbackrest --stanza=demo --type=full backup

pg-primary ⇒ Check file total

sudo -u postgres find /var/lib/pgbackrest/backup/demo/latest/ -type f | wc -l
5

Tune bundles with repo-bundle-size and repo-bundle-limit. The defaults should suit most cases.

Bundles usually improve efficiency, but make manual file retrieval harder. They might also be unsuitable for deduplicated storage because each full backup arranges files differently. Bundles cannot resume after interruption. Avoid a very high repo-bundle-limit.

Block Incremental

Block incremental backups store only file parts changed since the previous backup. This saves space compared with storing entire files.

Enable block incremental backups with repo-block. They work best when enabled for every backup type. File bundles must also be enabled.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-block

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

Backup Annotations

Attach informative key/value pairs to the backup. Repeat this option to attach multiple annotations.

pg-primary ⇒ Perform a full backup with annotations

sudo -u postgres pgbackrest --stanza=demo --annotation=source="demo backup" \
       --annotation=key=value --type=full backup

When --set specifies a backup, the info command includes its annotations in text output. JSON output always includes annotations.

pg-primary ⇒ Get info for the demo cluster

sudo -u postgres pgbackrest --stanza=demo --set=20260927-101013F info
stanza: demo
    status: ok
    cipher: aes-256-cbc

    db (current)
        wal archive min/max (14): 000000020000000000000007/000000020000000000000009

        full backup: 20260927-101013F
            timestamp start/stop: 2026-09-27 10:10:13+00 / 2026-09-27 10:10:15+00
            wal start/stop: 000000020000000000000008 / 000000020000000000000009
            lsn start/stop: 0/8000028 / 0/9000050
            database size: 25.2MB, database backup size: 25.2MB
            repo1: backup size: 3.2MB
            database list: postgres (13755)

            annotation(s)

                key: value
                source: demo backup

Use annotate to add, change, or remove annotations after the backup command creates a backup.

pg-primary ⇒ Change backup annotations

sudo -u postgres pgbackrest --stanza=demo --set=20260927-101013F \
       --annotation=key= --annotation=new_key=new_value annotate
sudo -u postgres pgbackrest --stanza=demo --set=20260927-101013F info
stanza: demo
    status: ok
    cipher: aes-256-cbc

    db (current)
        wal archive min/max (14): 000000020000000000000007/000000020000000000000009

        full backup: 20260927-101013F
            timestamp start/stop: 2026-09-27 10:10:13+00 / 2026-09-27 10:10:15+00
            wal start/stop: 000000020000000000000008 / 000000020000000000000009
            lsn start/stop: 0/8000028 / 0/9000050
            database size: 25.2MB, database backup size: 25.2MB
            repo1: backup size: 3.2MB
            database list: postgres (13755)

            annotation(s)

                new_key: new_value
                source: demo backup

Retention

Retain as many backups as practical to extend the Point-in-Time Recovery window. Account for limits such as disk space. Retention options remove backups when they are no longer needed.

pgBackRest rotates full backups according to a count or time period. Count-based retention keeps a specified number, regardless of creation times. Differential retention uses a count, but a differential always expires with its parent full backup. Incremental backups have no independent expiration policy. They expire with their parent full or differential backup. See Full Backup Retention and Differential Backup Retention for examples.

By default, pgBackRest keeps archived WAL for unexpired backups. You can change this per repository with retention-archive options, but this is not recommended. See Archive Retention.

The expire command runs automatically after each successful backup. You can also run it manually. A manual run applies each configured repository’s retention settings; --repo limits it to one repository. Use --set to expire a specific backup set. Without --repo, pgBackRest searches all repositories and expires sets that match. Every expire run also checks and applies archive retention.

Full Backup Retention

repo1-retention-full-type determines whether repo1-retention-full means a backup count or days of retention. New backups must complete before expiration. With repo1-retention-full-type=count and repo1-retention-full=2, three full backups exist before the oldest expires. With repo1-retention-full-type=time and repo1-retention-full=20, at least one full backup must be 20 days old before expiration.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-retention-full

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

repo1-retention-full=2, but only one full backup exists. The next full backup will not expire any full backups.

pg-primary ⇒ Perform a full backup

sudo -u postgres pgbackrest --stanza=demo --type=full \
       --log-level-console=detail backup
       [filtered 963 lines of output]
P00   INFO: repo1: remove expired backup 20260927-101011F
P00 DETAIL: repo1: 14-1 archive retention on backup 20260927-101013F, start = 000000020000000000000008

P00   INFO: repo1: 14-1 remove archive, start = 000000020000000000000007, stop = 000000020000000000000007

P00   INFO: expire command end: completed successfully

Archive data does expire because WAL segments exist from before the oldest backup. These cannot recover that backup. Recovery uses WAL generated after a backup.

pg-primary ⇒ Perform a full backup

sudo -u postgres pgbackrest --stanza=demo --type=full \
       --log-level-console=info backup
       [filtered 11 lines of output]
P00   INFO: repo1: expire full backup 20260927-101013F
P00   INFO: repo1: remove expired backup 20260927-101013F

P00   INFO: repo1: 14-1 remove archive, start = 000000020000000000000008, stop = 000000020000000000000009

P00   INFO: expire command end: completed successfully

Full backup 20260927-100955F expires. Archive retention now follows 20260927-101017F, the oldest remaining full backup.

Differential Backup Retention

Set repo1-retention-diff to the required differential backup count. Differentials depend only on the previous full backup. Keep a changing set covering the last day or longer for fast recent restores with less total space.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-retention-diff

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=1
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

With repo1-retention-diff=1, two differentials must complete before one expires. Add an incremental to demonstrate that it expires with its parent differential.

pg-primary ⇒ Perform differential and incremental backups

sudo -u postgres pgbackrest --stanza=demo --type=diff backup
sudo -u postgres pgbackrest --stanza=demo --type=incr backup

The next differential backup expires the previous differential and its incremental. One differential remains.

pg-primary ⇒ Perform a differential backup

sudo -u postgres pgbackrest --stanza=demo --type=diff \
       --log-level-console=info backup
       [filtered 10 lines of output]
P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=2639-d5ac017b --log-level-console=info --no-log-timestamp --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-diff=1 --repo1-retention-full=2 --stanza=demo
P00   INFO: repo1: expire diff backup set 20260927-101019F_20260927-101021D, 20260927-101019F_20260927-101022I
P00   INFO: repo1: remove expired backup 20260927-101019F_20260927-101022I
P00   INFO: repo1: remove expired backup 20260927-101019F_20260927-101021D
P00   INFO: expire command end: completed successfully

Archive Retention

By default, archive expiration follows full backup expiration through repo1-retention-full. You can expire archives more aggressively to save disk space. For differential archive retention, full backups also count as differentials.

Archive expiration never removes WAL needed for backup consistency. However, PITR needs a continuous WAL stream. Use care when expiring archives beyond normal backup expiration. To inspect proposed removals, run expire with command-line dry-run.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-retention-diff

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
start-fast=y
[global:archive-push]
compress-level=3

pg-primary ⇒ Perform differential backup

sudo -u postgres pgbackrest --stanza=demo --type=diff \
       --log-level-console=info backup
       [filtered 6 lines of output]
P00   INFO: backup stop archive = 000000020000000000000017, lsn = 0/17000050
P00   INFO: check archive for segment(s) 000000020000000000000016:000000020000000000000017
P00   INFO: new backup label = 20260927-101019F_20260927-101025D

P00   INFO: diff backup size = 11.5KB, file total = 951
P00   INFO: backup command end: completed successfully
       [filtered 2 lines of output]

pg-primary ⇒ Expire archive

sudo -u postgres pgbackrest --stanza=demo --log-level-console=detail \
       --repo1-retention-archive-type=diff --repo1-retention-archive=1 expire
P00   INFO: expire command begin 2.59.2: --exec-id=2876-36181f78 --log-level-console=detail --no-log-timestamp --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo1-retention-archive=1 --repo1-retention-archive-type=diff --repo1-retention-diff=2 --repo1-retention-full=2 --stanza=demo
P00 DETAIL: repo1: 14-1 archive retention on backup 20260927-101017F, start = 00000002000000000000000A, stop = 00000002000000000000000B
P00 DETAIL: repo1: 14-1 archive retention on backup 20260927-101019F, start = 00000002000000000000000C, stop = 00000002000000000000000D
P00 DETAIL: repo1: 14-1 archive retention on backup 20260927-101019F_20260927-101023D, start = 000000020000000000000012, stop = 000000020000000000000013
P00 DETAIL: repo1: 14-1 archive retention on backup 20260927-101019F_20260927-101025D, start = 000000020000000000000016
P00   INFO: repo1: 14-1 remove archive, start = 00000002000000000000000E, stop = 000000020000000000000011
P00   INFO: repo1: 14-1 remove archive, start = 000000020000000000000014, stop = 000000020000000000000015

P00   INFO: expire command end: completed successfully

WAL for 20260927-101019F_20260927-101023D must remain to make older backups consistent, although those backups can no longer support further PITR. Segments generated after 20260927-101019F_20260927-101023D and before 20260927-101019F_20260927-101025D are removed. Segments after the new backup 20260927-101019F_20260927-101025D remain available for PITR.

Full backups count as differentials for differential archive retention. With these settings, a new full backup retains only its own archive for PITR.


Restore

By default, restore selects the latest backup from the first repository with backups. See Quick Start - Restore a Backup. Repository order comes from pgbackrest.conf; for example, repo1 precedes repo2. Use --repo, such as --repo=1, to select a repository. Use --set to select a backup other than the latest.

For PITR with --type=time or --type=lsn, specify the target time or LSN with --target. Without --set, pgBackRest searches configured repositories in order for a backup containing that time or LSN. If none matches, --type=time uses the latest backup in the first repository with backups. For --type=lsn, it selects no backup. For other types, such as xid, use --set if the target precedes the latest backup. See Point-in-Time Recovery.

Backups exclude replication slots, as PostgreSQL recommends. See Backing Up The Data Directory.

The following sections introduce additional restore command features.

File Ownership

A typical restore runs as a non-root user. All restored files belong to the executing user and group. Existing files with other ownership cause an error if pgBackRest cannot change their ownership. Have a privileged user correct the ownership before retrying.

When restore runs as root, pgBackRest attempts to recreate manifest ownership. The manifest stores user/group names, so matching names must exist locally. If a name is absent, use the PostgreSQL data directory owner or group. If that identity also lacks a name, use root.

Delta Option

Restore a Backup in Quick Start required an empty cluster directory before restore. The delta option identifies files that can remain and files that need replacement. It also removes files absent from the manifest, including divergent changes. pgBackRest calculates a SHA-1 hash for each existing file. A file whose SHA-1 differs from the backup is restored.

Use process-max to speed this operation. PostgreSQL is stopped during restore, so you can use more processes than during an online backup.

pg-primary ⇒ Stop the demo cluster, perform delta restore

sudo systemctl stop postgresql-14.service
sudo -u postgres pgbackrest --stanza=demo --delta \
       --log-level-console=detail restore
       [filtered 2 lines of output]
P00 DETAIL: check '/var/lib/pgsql/14/data' exists
P00 DETAIL: remove 'global/pg_control' so cluster will not start if restore does not complete

P00   INFO: remove invalid files/links/paths from '/var/lib/pgsql/14/data'

P00 DETAIL: remove invalid file '/var/lib/pgsql/14/data/backup_label.old'
P00 DETAIL: remove invalid file '/var/lib/pgsql/14/data/base/13755/pg_internal.init'
       [filtered 996 lines of output]

pg-primary ⇒ Restart PostgreSQL

sudo systemctl start postgresql-14.service

Restore Selected Databases

Restore selected databases to improve performance or use a destination with insufficient space for the entire cluster backup.

Create test1 and test2 to demonstrate selective restore.

pg-primary ⇒ Create two test databases

sudo -u postgres psql -c "create database test1;"
CREATE DATABASE
sudo -u postgres psql -c "create database test2;"
CREATE DATABASE

Add tables and data to each test database to verify recovery after selective restore.

pg-primary ⇒ Create a test table in each database

sudo -u postgres psql -c "create table test1_table (id int); \
       insert into test1_table (id) values (1);" test1
CREATE TABLE
INSERT 0 1
sudo -u postgres psql -c "create table test2_table (id int); \
       insert into test2_table (id) values (2);" test2
CREATE TABLE
INSERT 0 1

Take a new backup that includes the new databases.

pg-primary ⇒ Perform a backup

sudo -u postgres pgbackrest --stanza=demo --type=incr backup

Selective restore can save space. Record test1 disk use now for comparison after the restore.

pg-primary ⇒ Show space used by test1 database

sudo -u postgres du -sh /var/lib/pgsql/14/data/base/32768
8.4M	/var/lib/pgsql/14/data/base/32768

To find available databases, run info with set to list the backup set contents.

pg-primary ⇒ Show database list for backup

sudo -u postgres pgbackrest --stanza=demo \
       --set=20260927-101019F_20260927-101034I info
       [filtered 12 lines of output]
            repo1: backup size: 2.1MB
            backup reference list: 20260927-101019F, 20260927-101019F_20260927-101025D

            database list: postgres (13755), test1 (32768), test2 (32769)

Stop the cluster and restore only the test2 database. Built-in databases (template0, template1, and postgres) are always restored.

WARNING:

Recovery can fail without --type=immediate. After consistency, PostgreSQL treats zeroed pages as errors, even with full-page writes. PostgreSQL ≥ 13 can use ignore_invalid_pages to ignore invalid pages. If you use this setting, check recovery logs for invalid pages in the selected databases.

pg-primary ⇒ Restore from last backup including only the test2 database

sudo systemctl stop postgresql-14.service
sudo -u postgres pgbackrest --stanza=demo --delta \
       --db-include=test2 --type=immediate --target-action=promote restore

sudo systemctl start postgresql-14.service

After recovery, test2 contains all previously created tables and data.

pg-primary ⇒ Demonstrate that the test2 database was recovered

sudo -u postgres psql -c "select * from test2_table;" test2
 id
----
  2
(1 row)

Although recovery succeeded, test1 is inaccessible. Its files were restored as sparse, zeroed files. PostgreSQL can replay WAL into them, but empty essential files leave the database invalid. This intentionally prevents use of a database that might contain only partial data from WAL replay.

pg-primary ⇒ Attempting to connect to the test1 database will produce an error

sudo -u postgres psql -c "select * from test1_table;" test1
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: FATAL:  relation mapping file "base/32768/pg_filenode.map" contains invalid data

Sparse, zeroed test1 files use space only for WAL written during recovery. Backup and recovery WAL volumes can be substantial. However, they are usually a small fraction of database size, especially for large databases that benefit most from selective restore.

The selective restore uses much less disk space for test1 than a complete restore would.

pg-primary ⇒ Show space used by test1 database after recovery

sudo -u postgres du -sh /var/lib/pgsql/14/data/base/32768
8.0K	/var/lib/pgsql/14/data/base/32768

Only drop database can now operate on invalid test1. pgBackRest does not drop it automatically because this requires completed recovery and an accessible cluster.

pg-primary ⇒ Drop the test1 database

sudo -u postgres psql -c "drop database test1;"
DROP DATABASE

After dropping invalid test1, only test2 and the built-in databases remain.

pg-primary ⇒ List remaining databases

sudo -u postgres psql -c "select oid, datname from pg_database order by oid;"
  oid  |  datname
-------+-----------
     1 | template1
 13754 | template0
 13755 | postgres

 32769 | test2

(4 rows)

Point-in-Time Recovery

Restore a Backup in Quick Start replayed WAL to the end of the stream. This is usually best after hardware failure. For data corruption caused by machines or people, Point-in-Time Recovery (PITR) is often more suitable.

PITR replays WAL from a backup to a specified LSN, time, transaction ID, or recovery point. Time-based recovery is often the most useful choice. This example recovers an accidentally dropped table. Use the same method for accidentally deleted data.

pg-primary ⇒ Create a table with very important data

sudo -u postgres psql -c "begin; \
       create table important_table (message text); \
       insert into important_table values ('Important Data'); \
       commit; \
       select * from important_table;"
       [filtered 4 lines of output]
    message
----------------

 Important Data

(1 row)

Use PostgreSQL time and include the timezone offset. This reduces unintended timezone conversions and unexpected recovery results.

pg-primary ⇒ Get the time from PostgreSQL

sudo -u postgres psql -Atc "select current_timestamp"
2026-09-27 10:10:45.829508+00

After recording the time, drop the table. In a real incident, the exact drop time can be harder or impossible to find. Investigation should help you estimate it.

pg-primary ⇒ Drop the important table

sudo -u postgres psql -c "begin; \
       drop table important_table; \
       commit; \
       select * from important_table;"
BEGIN
DROP TABLE
COMMITERROR:  relation "important_table" does not exist

LINE 1: ...le important_table;     commit;     select * from important_...
                                                             ^

A backup taken after the target cannot recover to that target. To demonstrate this, take an incremental backup without important_table.

pg-primary ⇒ Perform an incremental backup

sudo -u postgres pgbackrest --stanza=demo --type=incr backup
sudo -u postgres pgbackrest info
       [filtered 38 lines of output]
            backup reference total: 1 full, 1 diff
        incr backup: 20260927-101019F_20260927-101047I
            timestamp start/stop: 2026-09-27 10:10:47+00 / 2026-09-27 10:10:48+00
            wal start/stop: 00000004000000000000001A / 00000004000000000000001A
       [filtered 2 lines of output]

This backup cannot recover the lost table. PostgreSQL replays WAL forward and cannot reverse it.

pg-primary ⇒ Attempt recovery from an incorrect backup

sudo systemctl stop postgresql-14.service
sudo -u postgres pgbackrest --stanza=demo --delta \
       --set=20260927-101019F_20260927-101047I --target-timeline=current \
       --type=time "--target=2026-09-27 10:10:45.829508+00" --target-action=promote restore

sudo systemctl start postgresql-14.service
sudo -u postgres cat /var/lib/pgsql/14/data/log/postgresql.log
       [filtered 11 lines of output]
LOG:  database system is ready to accept read-only connections
LOG:  redo done at 0/1A000100 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.01 s

FATAL:  recovery ended before configured recovery target was reached
LOG:  startup process (PID 4043) exited with exit code 1
LOG:  terminating any other active server processes
LOG:  database system is shut down

Let pgBackRest select a backup that completed before the target time and can recover to it.

NOTE:

pgBackRest cannot automatically select a backup when the restore type is xid or name.

pg-primary ⇒ Restore the demo cluster to 2026-08-17 04:44:30.009846+00

sudo -u postgres pgbackrest --stanza=demo --delta \
       --type=time "--target=2026-09-27 10:10:45.829508+00" \
       --target-action=promote restore

sudo -u postgres cat /var/lib/pgsql/14/data/postgresql.auto.conf
       [filtered 9 lines of output]
# Recovery settings generated by pgBackRest restore on 2026-09-27 10:10:53
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
recovery_target_time = '2026-09-27 10:10:45.829508+00'
recovery_target_action = 'promote'

pgBackRest wrote recovery settings to postgresql.auto.conf, so start PostgreSQL immediately. PostgreSQL uses %f for the required WAL segment and %p for its destination. After recovery, the table exists and accepts queries again.

pg-primary ⇒ Start PostgreSQL and check that the important table exists

sudo systemctl start postgresql-14.service
sudo -u postgres psql -c "select * from important_table"
    message
----------------

 Important Data

(1 row)

The PostgreSQL log shows the recovery stop time and transaction. It also shows the time of the last applied transaction.

pg-primary ⇒ Examine the PostgreSQL log output

sudo -u postgres cat /var/lib/pgsql/14/data/log/postgresql.log
       [filtered 5 lines of output]
LOG:  database system was interrupted; last known up at 2026-09-27 10:10:34 UTC
LOG:  restored log file "00000004.history" from archive
LOG:  starting point-in-time recovery to 2026-09-27 10:10:45.829508+00

LOG:  restored log file "00000004.history" from archive
LOG:  restored log file "000000040000000000000019" from archive
       [filtered 2 lines of output]
LOG:  consistent recovery state reached at 0/19000100
LOG:  database system is ready to accept read-only connections
LOG:  recovery stopping before commit of transaction 743, time 2026-09-27 10:10:47.12347+00
LOG:  redo done at 0/1901E6C0 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.02 s
LOG:  last completed transaction was at log time 2026-09-27 10:10:44.508155+00

LOG:  selected new timeline ID: 5
LOG:  archive recovery complete
LOG:  database system is ready to accept connections

Delete a Stanza

The stanza-delete command removes repository data for a stanza.

WARNING:

Use this command with care. It permanently removes every backup and archive for the specified stanza from the pgBackRest repository.

To delete a stanza:

  • Shut down the PostgreSQL cluster associated with the stanza (or use –force to override).
  • Run the stop command on the host where the stanza-delete command will be run.
  • Run the stanza-delete command.

After the command succeeds, remove the stanza from all applicable pgBackRest configuration files and environment variables.

Delete a stanza from one repository at a time. For multiple repositories, repeat stanza-delete with --repo for each repository.

pg-primary ⇒ Stop PostgreSQL cluster to be removed

sudo systemctl stop postgresql-14.service

pg-primary ⇒ Stop pgBackRest for the stanza

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stop
P00   INFO: stop command begin 2.59.2: --exec-id=4393-45b06995 --log-level-console=info --no-log-timestamp --stanza=demo

P00   INFO: stop command end: completed successfully

pg-primary ⇒ Delete the stanza from one repository

sudo -u postgres pgbackrest --stanza=demo --repo=1 \
       --log-level-console=info stanza-delete
P00   INFO: stanza-delete command begin 2.59.2: --exec-id=4425-535620df --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo=1 --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --stanza=demo

P00   INFO: stanza-delete command end: completed successfully

Multiple Repositories

Configure multiple repositories as shown in S3 Support. For example, use a local repository for fast restores and a remote repository for redundancy.

Commands such as stanza-create and stanza-upgrade automatically use all repositories. Others, such as stanza-delete, require a repo selection.

For compatibility, repo is optional when only repo1 is configured. It is required when the only repository has another index, such as repo2. This prevents command failures if another repository is added later.

archive-push sends WAL to all configured repositories. If one is unreachable, it still sends WAL to the others. Enable archive-async=y for effective independent progress. Otherwise, the other repositories can advance only one segment beyond the unreachable repository. If WAL cannot reach any repository, PostgreSQL keeps it in pg_wal. This can fill the volume.

Schedule backups separately for each repository. This lets you vary backup types and retention. Specify a repository for restores as well. A repository with low latency or cost is usually preferable, even with longer recovery time. Test restores to determine which is most efficient.


Azure-Compatible Object Store Support

pgBackRest supports repositories in Azure-compatible object stores. Create the container first; pgBackRest does not create it. You can use the container root (/). Usually, prefer a subpath so object-store logs and other data can share the container without conflicts.

WARNING:

Do not enable “hierarchical namespace” as this will cause errors during expire.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure Azure

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
repo2-azure-account=pgbackrest
repo2-azure-container=demo-container
repo2-azure-key=YXpLZXk=
repo2-path=/demo-repo
repo2-retention-full=4
repo2-type=azure
start-fast=y
[global:archive-push]
compress-level=3

For a shared access signature, set repo2-azure-key-type to sas. Set repo2-azure-key to the signature token.

Run commands as you would for a repository on a local disk.

pg-primary ⇒ Create the stanza

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
P00   INFO: stanza-create command begin 2.59.2: --exec-id=4632-06271e3e --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo2-type=azure --stanza=demo
P00   INFO: stanza-create for stanza 'demo' on repo1
P00   INFO: stanza-create for stanza 'demo' on repo2

P00   INFO: stanza-create command end: completed successfully

Azure file creation is relatively slow. Enable file bundling to improve backup/restore performance.

pg-primary ⇒ Backup the demo cluster

sudo -u postgres pgbackrest --stanza=demo --repo=2 \
       --log-level-console=info backup
P00   INFO: backup command begin 2.59.2: --exec-id=4665-2f3276f7 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo=2 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-block --repo1-bundle --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo2-type=azure --stanza=demo --start-fast

P00   WARN: no prior backup exists, incr backup has been changed to full

P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 00000005000000000000001B, lsn = 0/1B000028
       [filtered 3 lines of output]
P00   INFO: check archive for segment(s) 00000005000000000000001B:00000005000000000000001B
P00   INFO: new backup label = 20260927-101107F

P00   INFO: full backup size = 33.5MB, file total = 1249

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=4665-2f3276f7 --log-level-console=info --no-log-timestamp --repo=2 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo2-type=azure --stanza=demo

S3-Compatible Object Store Support

pgBackRest supports repositories in S3-compatible object stores. Create the bucket first; pgBackRest does not create it. You can use the bucket root (/). Usually, prefer a subpath so object-store logs and other data can share the bucket without conflicts.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure S3

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
repo2-azure-account=pgbackrest
repo2-azure-container=demo-container
repo2-azure-key=YXpLZXk=
repo2-path=/demo-repo
repo2-retention-full=4
repo2-type=azure
repo3-path=/demo-repo
repo3-retention-full=4
repo3-s3-bucket=demo-bucket
repo3-s3-endpoint=s3.us-east-1.amazonaws.com
repo3-s3-key=accessKey1
repo3-s3-key-secret=verySecretKey1
repo3-s3-region=us-east-1
repo3-type=s3
start-fast=y
[global:archive-push]
compress-level=3

NOTE:

Set the region and endpoint for the bucket location. These examples use us-east-1.

Create a role for pgBackRest and restrict bucket permissions as much as possible. For an AWS instance-associated role, set repo3-s3-key-type=auto to retrieve temporary credentials automatically. You then do not need explicit keys in /etc/pgbackrest/pgbackrest.conf.

This sample Amazon S3 policy will restrict all reads and writes to the bucket and repository path.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::demo-bucket"
            ],
            "Condition": {
                "StringEquals": {
                    "s3:prefix": [
                        "",
                        "demo-repo"
                    ],
                    "s3:delimiter": [
                        "/"
                    ]
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::demo-bucket"
            ],
            "Condition": {
                "StringLike": {
                    "s3:prefix": [
                        "demo-repo/*"
                    ]
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:PutObjectTagging",
                "s3:GetObject",
                "s3:GetObjectVersion",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::demo-bucket/demo-repo/*"
            ]
        }
    ]
}

Run commands as you would for a repository on a local disk.

pg-primary ⇒ Create the stanza

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
       [filtered 4 lines of output]
P00   INFO: stanza 'demo' already exists on repo2 and is valid
P00   INFO: stanza-create for stanza 'demo' on repo3

P00   INFO: stanza-create command end: completed successfully

S3 file creation is relatively slow. Enable file bundling to improve backup/restore performance.

pg-primary ⇒ Backup the demo cluster

sudo -u postgres pgbackrest --stanza=demo --repo=3 \
       --log-level-console=info backup
P00   INFO: backup command begin 2.59.2: --exec-id=5058-a4816496 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo=3 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-block --repo1-bundle --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo2-type=azure --repo3-type=s3 --stanza=demo --start-fast

P00   WARN: no prior backup exists, incr backup has been changed to full

P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 00000005000000000000001D, lsn = 0/1D000028
       [filtered 3 lines of output]
P00   INFO: check archive for segment(s) 00000005000000000000001D:00000005000000000000001D
P00   INFO: new backup label = 20260927-101125F

P00   INFO: full backup size = 33.5MB, file total = 1249

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=5058-a4816496 --log-level-console=info --no-log-timestamp --repo=3 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo2-type=azure --repo3-type=s3 --stanza=demo

SFTP Support

pgBackRest supports repositories on SFTP hosts. SFTP transfers are relatively slow. Increase process-max to transfer files in parallel.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure SFTP

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
process-max=4
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
repo2-azure-account=pgbackrest
repo2-azure-container=demo-container
repo2-azure-key=YXpLZXk=
repo2-path=/demo-repo
repo2-retention-full=4
repo2-type=azure
repo3-path=/demo-repo
repo3-retention-full=4
repo3-s3-bucket=demo-bucket
repo3-s3-endpoint=s3.us-east-1.amazonaws.com
repo3-s3-key=accessKey1
repo3-s3-key-secret=verySecretKey1
repo3-s3-region=us-east-1
repo3-type=s3
repo4-bundle=y
repo4-path=/demo-repo
repo4-sftp-host=sftp-server
repo4-sftp-host-key-hash-type=sha1
repo4-sftp-host-user=pgbackrest
repo4-sftp-private-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp
repo4-sftp-public-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp.pub
repo4-type=sftp
start-fast=y
[global:archive-push]
compress-level=3

For SFTP with libssh2 compiled against OpenSSH, repo4-sftp-public-key-file is optional.

pg-primary ⇒ Generate SSH keypair for SFTP backup

sudo -u postgres mkdir -m 750 -p /var/lib/pgsql/.ssh
sudo -u postgres ssh-keygen -f /var/lib/pgsql/.ssh/id_rsa_sftp \
       -t rsa -b 4096 -N "" -m PEM

sftp-server ⇒ Copy pg-primary SFTP backup public key to sftp-server

sudo -u pgbackrest mkdir -m 750 -p /home/pgbackrest/.ssh

(sudo ssh root@pg-primary cat /var/lib/pgsql/.ssh/id_rsa_sftp.pub) | \
       sudo -u pgbackrest tee -a /home/pgbackrest/.ssh/authorized_keys

Run commands as you would for a repository on a local disk.

pg-primary ⇒ Add sftp-server fingerprint to known_hosts file since repo4-sftp-host-key-check-type defaults to “strict”

ssh-keyscan -H sftp-server >> /var/lib/pgsql/.ssh/known_hosts 2>/dev/null

pg-primary ⇒ Create the stanza

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info stanza-create
       [filtered 6 lines of output]
P00   INFO: stanza 'demo' already exists on repo3 and is valid
P00   INFO: stanza-create for stanza 'demo' on repo4

P00   INFO: stanza-create command end: completed successfully

pg-primary ⇒ Backup the demo cluster

sudo -u postgres pgbackrest --stanza=demo --repo=4 \
       --log-level-console=info backup
P00   INFO: backup command begin 2.59.2: --exec-id=5360-3acf49a0 --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --process-max=4 --repo=4 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-block --repo1-bundle --repo4-bundle --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo4-sftp-host=sftp-server --repo4-sftp-host-key-hash-type=sha1 --repo4-sftp-host-user=pgbackrest --repo4-sftp-private-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp.pub --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --stanza=demo --start-fast
P00   WARN: option 'repo4-retention-full' is not set for 'repo4-retention-full-type=count', the repository may run out of space
            HINT: to retain full backups indefinitely (without warning), set option 'repo4-retention-full' to the maximum.

P00   WARN: no prior backup exists, incr backup has been changed to full

P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 00000005000000000000001E, lsn = 0/1E000028
       [filtered 3 lines of output]
P00   INFO: check archive for segment(s) 00000005000000000000001E:00000005000000000000001F
P00   INFO: new backup label = 20260927-101141F

P00   INFO: full backup size = 33.5MB, file total = 1249

P00   INFO: backup command end: completed successfully
P00   INFO: expire command begin 2.59.2: --exec-id=5360-3acf49a0 --log-level-console=info --no-log-timestamp --repo=4 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo1-retention-diff=2 --repo1-retention-full=2 --repo2-retention-full=4 --repo3-retention-full=4 --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo4-sftp-host=sftp-server --repo4-sftp-host-key-hash-type=sha1 --repo4-sftp-host-user=pgbackrest --repo4-sftp-private-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp.pub --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --stanza=demo
P00   INFO: expire command end: completed successfully

GCS-Compatible Object Store Support

pgBackRest supports repositories in GCS-compatible object stores. Create the bucket first; pgBackRest does not create it. You can use the bucket root (/). Usually, prefer a subpath so object-store logs and other data can share the bucket without conflicts.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure GCS

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
process-max=4
repo1-block=y
repo1-bundle=y
repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO
repo1-cipher-type=aes-256-cbc
repo1-path=/var/lib/pgbackrest
repo1-retention-diff=2
repo1-retention-full=2
repo2-azure-account=pgbackrest
repo2-azure-container=demo-container
repo2-azure-key=YXpLZXk=
repo2-path=/demo-repo
repo2-retention-full=4
repo2-type=azure
repo3-path=/demo-repo
repo3-retention-full=4
repo3-s3-bucket=demo-bucket
repo3-s3-endpoint=s3.us-east-1.amazonaws.com
repo3-s3-key=accessKey1
repo3-s3-key-secret=verySecretKey1
repo3-s3-region=us-east-1
repo3-type=s3
repo4-bundle=y
repo4-path=/demo-repo
repo4-sftp-host=sftp-server
repo4-sftp-host-key-hash-type=sha1
repo4-sftp-host-user=pgbackrest
repo4-sftp-private-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp
repo4-sftp-public-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp.pub
repo4-type=sftp
repo5-gcs-bucket=demo-bucket
repo5-gcs-key=/etc/pgbackrest/gcs-key.json
repo5-path=/demo-repo
repo5-type=gcs
start-fast=y
[global:archive-push]
compress-level=3

On GCE, set repo5-gcs-key-type=auto to authenticate through the instance service account.

Run commands as you would for a repository on a local disk.

GCS file creation is relatively slow. Enable file bundling to improve backup/restore performance.


Target Time for Repository

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

Delete the S3 repository demo stanza to demonstrate recovery from versioned storage.

pg-primary ⇒ Delete stanza in S3 repository

sudo systemctl stop postgresql-14.service
sudo -u postgres pgbackrest --stanza=demo stop
sudo -u postgres pgbackrest --stanza=demo --repo=3 stanza-delete

After deletion, info reports a repository error.

pg-primary ⇒ Error on info

sudo -u postgres pgbackrest --stanza=demo --repo=3 info
stanza: demo

    status: error (missing stanza path)

Versioned storage lets you read the repository before deletion. Finding the target time can be difficult. Here, use the deletion time of backup.info to identify when the stanza was deleted.

pg-primary ⇒ List versions of backup.info in the bucket

key=demo-repo/backup/demo/backup.info; \
       aws s3api list-object-versions --bucket demo-bucket \
       --prefix $key --output table \
       --query "sort_by([Versions[?Key=='$key'].{Action:'PUT', \
       Modified:LastModified,Object:Key}, \
       DeleteMarkers[?Key=='$key'].{Action:'DELETE', \
       Modified:LastModified,Object:Key}][],&Modified)"
-------------------------------------------------------------------------------------
|                                ListObjectVersions                                 |
+--------+------------------------------------+-------------------------------------+
| Action |             Modified               |               Object                |
+--------+------------------------------------+-------------------------------------+
|  PUT   |  2026-09-27T10:11:25.317000+00:00  |  demo-repo/backup/demo/backup.info  |
|  PUT   |  2026-09-27T10:11:38.216000+00:00  |  demo-repo/backup/demo/backup.info  |
|  DELETE|  2026-09-27T10:11:50.305000+00:00  |  demo-repo/backup/demo/backup.info  |
+--------+------------------------------------+-------------------------------------+

Run info with a target time before deletion to view the repository.

pg-primary ⇒ Info with target time

sudo -u postgres pgbackrest --stanza=demo --repo=3 \
       --repo-target-time="2026-09-27 10:11:38+00" info
       [filtered 5 lines of output]
        wal archive min/max (14): 00000005000000000000001C/00000005000000000000001D
        full backup: 20260927-101125F
            timestamp start/stop: 2026-09-27 10:11:25+00 / 2026-09-27 10:11:37+00
            wal start/stop: 00000005000000000000001D / 00000005000000000000001D
            repo3: backup set size: 4.2MB, backup size: 4.2MB

If info shows the required backup, restore it with the same target time.

pg-primary ⇒ Restore with target time

sudo -u postgres pgbackrest --stanza=demo --repo=3 --delta \
       --repo-target-time="2026-09-27 10:11:38+00" --log-level-console=info restore
P00   INFO: restore command begin 2.59.2: --delta --exec-id=5687-73aa017d --log-level-console=info --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --process-max=4 --repo=3 --repo2-azure-account=<redacted> --repo2-azure-container=demo-container --repo2-azure-key=<redacted> --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo5-gcs-bucket=demo-bucket --repo5-gcs-key=<redacted> --repo1-path=/var/lib/pgbackrest --repo2-path=/demo-repo --repo3-path=/demo-repo --repo4-path=/demo-repo --repo5-path=/demo-repo --repo3-s3-bucket=demo-bucket --repo3-s3-endpoint=s3.us-east-1.amazonaws.com --repo3-s3-key=<redacted> --repo3-s3-key-secret=<redacted> --repo3-s3-region=us-east-1 --repo4-sftp-host=sftp-server --repo4-sftp-host-key-hash-type=sha1 --repo4-sftp-host-user=pgbackrest --repo4-sftp-private-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp --repo4-sftp-public-key-file=/var/lib/pgsql/.ssh/id_rsa_sftp.pub --repo-target-time="2026-09-27 10:11:38+00" --repo2-type=azure --repo3-type=s3 --repo4-type=sftp --repo5-type=gcs --stanza=demo
P00   INFO: repo3: restore backup set 20260927-101125F, recovery will start at 2026-09-27 10:11:25

P00   INFO: remove invalid files/links/paths from '/var/lib/pgsql/14/data'
P00   INFO: write updated /var/lib/pgsql/14/data/postgresql.auto.conf
       [filtered 2 lines of output]
sudo systemctl start postgresql-14.service

Dedicated Repository Host

Quickstart suits simple installations. Enterprise installations commonly use a separate repository host for backups and WAL archives. This reduces the effect of database host failures on backup data. Also consider conventional backup software for the repository host.

On each PostgreSQL host, set pg1-path to the local cluster path and leave pg1-host unset. On the repository host, configure pg-host connections to the primary and any standby hosts. Only the repository host configuration should list multiple PostgreSQL hosts. Either index can identify the primary or standby; for example, pg1-path/pg1-host and pg2-path/pg2-host can appear in either order.

Installation

Create a host named repository to store cluster backups.

NOTE:

The pgBackRest version installed on the repository host must exactly match the version installed on the PostgreSQL host.

Create pgbackrest as the repository owner. Any user can own it, but avoid postgres, if present, to prevent confusion.

NOTE:

A pgBackRest package might install logrotate configuration, such as /etc/logrotate.d/pgbackrest, with a su directive like su postgres postgres. Files in /var/log/pgbackrest belong to the user running pgBackRest, here pgbackrest. Update su to that user. Otherwise, logrotate fails with a permission error.

repository ⇒ Create pgbackrest user

sudo groupadd pgbackrest
sudo adduser -gpgbackrest -n pgbackrest

Prefer package installation to a source build. Packages usually perform the remaining steps in this section. If a package omits a directory or sets incorrect permissions, create the directory or correct its permissions manually.

RHEL packages for pgBackRest are available at yum.postgresql.org.

If your distribution or version has no package, build from source and follow these manual installation steps.

repository ⇒ Install dependencies

sudo yum install postgresql-libs libssh2

repository ⇒ Copy pgBackRest binary from build host

sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest

pgBackRest requires log and configuration directories and a configuration file.

repository ⇒ Create pgBackRest configuration file and directories

sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown pgbackrest:pgbackrest /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown pgbackrest:pgbackrest /etc/pgbackrest/pgbackrest.conf

repository ⇒ Create the pgBackRest repository

sudo mkdir -p /var/lib/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
sudo chown pgbackrest:pgbackrest /var/lib/pgbackrest

Configuration

Use TLS and client certificates for communication between hosts. SSH is also supported; see Setup SSH.

Generate pgBackRest client and server certificates as you would for PostgreSQL. See Secure TCP/IP Connections with TLS.

On the repository host, configure the pg-primary host, user, and database path. Use pg1 for the primary so you can add a standby later.

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pg1-host/pg1-host-user and pg1-path

[demo]
pg1-host=pg-primary
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/14/data
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
tls-server-address=*
tls-server-auth=pgbackrest-client=*
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

On the database host, configure the repository host and user. repo1-host-user defaults to pgbackrest. If postgres performs restores on the repository host, preferably prevent it from also performing backups. It can read the repository directly if it belongs to the pgbackrest group.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure repo1-host/repo1-host-user

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
log-level-file=detail
repo1-host=repository
repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt
repo1-host-cert-file=/etc/pgbackrest/cert/client.crt
repo1-host-key-file=/etc/pgbackrest/cert/client.key
repo1-host-type=tls
tls-server-address=*
tls-server-auth=pgbackrest-client=demo
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

See Configure Archiving for PostgreSQL configuration.

Commands work as in a single-host setup. However, run commands such as backup and expire on the repository host.

Setup TLS Server

The pgBackRest TLS server must be configured and started on each host.

repository ⇒ Setup pgBackRest Server

sudo cat /etc/systemd/system/pgbackrest.service
[Unit]
Description=pgBackRest Server
After=network.target
StartLimitIntervalSec=0
[Service]
Type=notify
Restart=always
RestartSec=1
User=pgbackrest
ExecStart=/usr/bin/pgbackrest server
ExecStartPost=/bin/sleep 3
ExecStartPost=/bin/bash -c "[ ! -z $MAINPID ]"
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
sudo systemctl enable pgbackrest
sudo systemctl start pgbackrest

pg-primary ⇒ Setup pgBackRest Server

sudo cat /etc/systemd/system/pgbackrest.service
[Unit]
Description=pgBackRest Server
After=network.target
StartLimitIntervalSec=0
[Service]
Type=notify
Restart=always
RestartSec=1
User=postgres
ExecStart=/usr/bin/pgbackrest server
ExecStartPost=/bin/sleep 3
ExecStartPost=/bin/bash -c "[ ! -z $MAINPID ]"
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
sudo systemctl enable pgbackrest
sudo systemctl start pgbackrest

Create and Check Stanza

Create the stanza in the new repository.

repository ⇒ Create the stanza

sudo -u pgbackrest pgbackrest --stanza=demo stanza-create

Check configuration on both the database and repository hosts. See Check the Configuration for check details.

pg-primary ⇒ Check the configuration

sudo -u postgres pgbackrest --stanza=demo check

repository ⇒ Check the configuration

sudo -u pgbackrest pgbackrest --stanza=demo check

Perform a Backup

On the repository host, run pgBackRest backup to back up the PostgreSQL cluster.

repository ⇒ Backup the demo cluster

sudo -u pgbackrest pgbackrest --stanza=demo backup
P00   WARN: no prior backup exists, incr backup has been changed to full

The new repository had no full backup. pgBackRest therefore warned that it changed the incremental backup to a full backup.

Restore a Backup

On the database host, run pgBackRest restore to restore the PostgreSQL cluster.

pg-primary ⇒ Stop the demo cluster, restore, and restart PostgreSQL

sudo systemctl stop postgresql-14.service
sudo -u postgres pgbackrest --stanza=demo --delta restore
sudo systemctl start postgresql-14.service

Parallel Backup / Restore

pgBackRest can compress and transfer data in parallel. Set the process count with --process-max.

Usually, allocate no more than 25% of available CPUs to backup. Regular backups do not need maximum speed. Avoid reducing database performance where possible.

Restore should use all available CPUs because PostgreSQL is stopped and usually no other critical work runs on that host. If the host has multiple clusters, account for them when setting parallelism.

repository ⇒ Perform a backup with single process

sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pgBackRest to use multiple backup processes

[demo]
pg1-host=pg-primary
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/14/data
[global]
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
tls-server-address=*
tls-server-auth=pgbackrest-client=*
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

repository ⇒ Perform a backup with multiple processes

sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup

repository ⇒ Get backup info for the demo cluster

sudo -u pgbackrest pgbackrest info
stanza: demo
    status: ok
    cipher: none

    db (current)
        wal archive min/max (14): 000000070000000000000023/000000070000000000000025

        full backup: 20260927-101240F
            timestamp start/stop: 2026-09-27 10:12:40+00 / 2026-09-27 10:12:44+00

            wal start/stop: 000000070000000000000023 / 000000070000000000000023
            database size: 33.5MB, database backup size: 33.5MB
            repo1: backup set size: 4.2MB, backup size: 4.2MB

        full backup: 20260927-101245F
            timestamp start/stop: 2026-09-27 10:12:45+00 / 2026-09-27 10:12:47+00

            wal start/stop: 000000070000000000000024 / 000000070000000000000025
            database size: 33.5MB, database backup size: 33.5MB
            repo1: backup set size: 4.2MB, backup size: 4.2MB

Multiple processes should speed up the last backup. For very small backups, the difference might be small. Time savings increase with database size.


Starting and Stopping

Prevent test clusters from writing to pgBackRest repositories with stop. This includes standbys promoted for testing and test clusters restored from production backups.

stop blocks these write commands: archive-push, backup, expire, stanza-create, and stanza-upgrade. The exception is stanza-delete; see Delete a Stanza.

pg-primary ⇒ Stop pgBackRest write commands

sudo -u postgres pgbackrest stop

New pgBackRest write commands cannot run.

repository ⇒ Attempt a backup

sudo -u pgbackrest pgbackrest --stanza=demo backup
P00   WARN: unable to check pg1: [StopError] raised from remote-0 tls protocol on 'pg-primary': stop file exists for all stanzas

P00  ERROR: [056]: unable to find primary cluster - cannot proceed
            HINT: are all available clusters in recovery?

Use --force to terminate running pgBackRest write commands. This also terminates asynchronous archive-get, although it restarts if PostgreSQL needs it. Repeating stop when pgBackRest is already stopped produces a warning.

pg-primary ⇒ Stop the pgBackRest services again

sudo -u postgres pgbackrest stop
P00   WARN: stop file already exists for all stanzas

Use start to permit pgBackRest write commands again. Previously interrupted commands do not restart automatically.

pg-primary ⇒ Start pgBackRest write commands

sudo -u postgres pgbackrest start

You can also stop pgBackRest for one stanza.

pg-primary ⇒ Stop pgBackRest write commands for the demo stanza

sudo -u postgres pgbackrest --stanza=demo stop

New pgBackRest write commands cannot run for this stanza.

repository ⇒ Attempt a backup

sudo -u pgbackrest pgbackrest --stanza=demo backup
P00   WARN: unable to check pg1: [StopError] raised from remote-0 tls protocol on 'pg-primary': stop file exists for stanza demo

P00  ERROR: [056]: unable to find primary cluster - cannot proceed
            HINT: are all available clusters in recovery?

When starting write commands for one stanza, specify that stanza again.

pg-primary ⇒ Start pgBackRest write commands for the demo stanza

sudo -u postgres pgbackrest --stanza=demo start

Replication

Replication creates standby copies of a PostgreSQL primary cluster. Standbys distribute read load and provide redundancy if the primary host fails.

Installation

Create a host named pg-standby for the standby.

Prefer package installation to a source build. Packages usually perform the remaining steps in this section. If a package omits a directory or sets incorrect permissions, create the directory or correct its permissions manually.

RHEL packages for pgBackRest are available at yum.postgresql.org.

If your distribution or version has no package, build from source and follow these manual installation steps.

pg-standby ⇒ Install dependencies

sudo yum install postgresql-libs libssh2

pg-standby ⇒ Copy pgBackRest binary from build host

sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest

pgBackRest requires log and configuration directories and a configuration file.

pg-standby ⇒ Create pgBackRest configuration file and directories

sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf

Hot Standby

A hot standby performs replication using the WAL archive and allows read-only queries.

Use configuration similar to pg-primary. Set recovery type standby to keep the cluster in recovery after it reaches the end of archived WAL.

pg-standby:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pgBackRest on the standby

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
log-level-file=detail
repo1-host=repository
repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt
repo1-host-cert-file=/etc/pgbackrest/cert/client.crt
repo1-host-key-file=/etc/pgbackrest/cert/client.key
repo1-host-type=tls
tls-server-address=*
tls-server-auth=pgbackrest-client=demo
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

pg-standby ⇒ Setup pgBackRest Server

sudo cat /etc/systemd/system/pgbackrest.service
[Unit]
Description=pgBackRest Server
After=network.target
StartLimitIntervalSec=0
[Service]
Type=notify
Restart=always
RestartSec=1
User=postgres
ExecStart=/usr/bin/pgbackrest server
ExecStartPost=/bin/sleep 3
ExecStartPost=/bin/bash -c "[ ! -z $MAINPID ]"
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
sudo systemctl enable pgbackrest
sudo systemctl start pgbackrest

Create the path where PostgreSQL will be restored.

pg-standby ⇒ Create PostgreSQL path

sudo -u postgres mkdir -p -m 700 /var/lib/pgsql/14/data

Create the standby with restore.

IMPORTANT:

If promotion is for testing or reporting rather than a new primary, disable archiving. Use --archive-mode=off or set archive_mode=off in postgresql.conf. Otherwise, the cluster can add conflicting WAL to the repository and complicate restores.

pg-standby ⇒ Restore the demo standby cluster

sudo -u postgres pgbackrest --stanza=demo --type=standby restore
sudo -u postgres cat /var/lib/pgsql/14/data/postgresql.auto.conf

# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:10:05
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:10:28
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:10:53
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
# Removed by pgBackRest restore on 2026-09-27 10:11:54 # recovery_target_time = '2026-09-27 10:10:45.829508+00'
# Removed by pgBackRest restore on 2026-09-27 10:11:54 # recovery_target_action = 'promote'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:11:54
restore_command = 'pgbackrest --repo=3 --repo-target-time="2026-09-27 10:11:38+00" --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:12:36
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:13:08
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

This configuration also supports later promotion of the standby to primary.

pg-standby:/var/lib/pgsql/14/data/postgresql.conf ⇒ Configure PostgreSQL

archive_command = 'pgbackrest --stanza=demo archive-push %p'
archive_mode = on

log_filename = 'postgresql.log'

pg-standby ⇒ Start PostgreSQL

sudo systemctl start postgresql-14.service

Check the PostgreSQL recovery log. It should show that the cluster entered standby mode and accepts read-only connections.

pg-standby ⇒ Examine the PostgreSQL log output for log messages indicating success

sudo -u postgres cat /var/lib/pgsql/14/data/log/postgresql.log
       [filtered 4 lines of output]
LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
LOG:  database system was interrupted; last known up at 2026-09-27 10:12:45 UTC

LOG:  entering standby mode

LOG:  restored log file "00000007.history" from archive
LOG:  restored log file "000000070000000000000024" from archive
       [filtered 3 lines of output]

To test replication, create a table on pg-primary.

pg-primary ⇒ Create a new table on the primary

sudo -u postgres psql -c " \
       begin; \
       create table replicated_table (message text); \
       insert into replicated_table values ('Important Data'); \
       commit; \
       select * from replicated_table";
       [filtered 4 lines of output]
    message
----------------

 Important Data

(1 row)

Then query that table on pg-standby.

pg-standby ⇒ Query new table on the standby

sudo -u postgres psql -c "select * from replicated_table;"
ERROR:  relation "replicated_table" does not exist

LINE 1: select * from replicated_table;
                      ^

The standby reads archived WAL. It cannot see changes until pg-primary archives the segment containing them.

Call pg_switch_wal() to archive the current WAL segment. PostgreSQL creates a new segment for later changes.

pg-primary ⇒ Call pg_switch_wal()

sudo -u postgres psql -c "select *, current_timestamp from pg_switch_wal()";
 pg_switch_wal |      current_timestamp
---------------+------------------------------
 0/2601E7C0    | 2026-09-27 10:13:14.65946+00
(1 row)

After a short delay, the table appears on pg-standby.

pg-standby ⇒ Now the new table exists on the standby (may require a few retries)

sudo -u postgres psql -c " \
       select *, current_timestamp from replicated_table"
    message     |       current_timestamp
----------------+-------------------------------
 Important Data | 2026-09-27 10:13:15.866308+00

(1 row)

Check the standby configuration for access to the repository.

pg-standby ⇒ Check the configuration

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=1284-bb81ebc5 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --stanza=demo
P00   INFO: check repo1 (standby)

P00   INFO: switch wal not performed because this is a standby

P00   INFO: check command end: completed successfully

Streaming Replication

Streaming replication connects directly to the primary and applies changes as they occur. This reduces primary-to-standby lag compared with archive-only replication.

Streaming replication requires a user with the replication privilege.

pg-primary ⇒ Create replication user

sudo -u postgres psql -c " \
       create user replicator password 'jw8s0F4' replication";
CREATE ROLE

Update pg_hba.conf to allow the standby to connect as the replication user. Replace the example IP address with your pg-standby address. Reload configuration after the change.

pg-primary ⇒ Create pg_hba.conf entry for replication user

sudo -u postgres sh -c 'echo \
       "host    replication     replicator      172.17.0.8/32           md5" \
       >> /var/lib/pgsql/14/data/pg_hba.conf'

sudo systemctl reload postgresql-14.service

Configure primary_conninfo in pgBackRest so the standby can contact the primary.

pg-standby:/etc/pgbackrest/pgbackrest.conf ⇒ Set primary_conninfo

[demo]
pg1-path=/var/lib/pgsql/14/data
recovery-option=primary_conninfo=host=172.17.0.6 port=5432 user=replicator
[global]
log-level-file=detail
repo1-host=repository
repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt
repo1-host-cert-file=/etc/pgbackrest/cert/client.crt
repo1-host-key-file=/etc/pgbackrest/cert/client.key
repo1-host-type=tls
tls-server-address=*
tls-server-auth=pgbackrest-client=demo
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

You can put a password in primary_conninfo, but a .pgpass file is more flexible and secure.

pg-standby ⇒ Configure the replication password in the .pgpass file.

sudo -u postgres sh -c 'echo \
       "172.17.0.6:*:replication:replicator:jw8s0F4" \
       >> /var/lib/pgsql/.pgpass'

sudo -u postgres chmod 600 /var/lib/pgsql/.pgpass

Create the standby with restore.

pg-standby ⇒ Stop PostgreSQL and restore the demo standby cluster

sudo systemctl stop postgresql-14.service
sudo -u postgres pgbackrest --stanza=demo --delta --type=standby restore
sudo -u postgres cat /var/lib/pgsql/14/data/postgresql.auto.conf

# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:10:05
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:10:28
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:10:53
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'
# Removed by pgBackRest restore on 2026-09-27 10:11:54 # recovery_target_time = '2026-09-27 10:10:45.829508+00'
# Removed by pgBackRest restore on 2026-09-27 10:11:54 # recovery_target_action = 'promote'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:11:54
restore_command = 'pgbackrest --repo=3 --repo-target-time="2026-09-27 10:11:38+00" --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:12:36
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

# Recovery settings generated by pgBackRest restore on 2026-09-27 10:13:21
primary_conninfo = 'host=172.17.0.6 port=5432 user=replicator'
restore_command = 'pgbackrest --stanza=demo archive-get %f "%p"'

NOTE:

pgBackRest wrote primary_conninfo to postgresql.auto.conf because pgbackrest.conf defines it as a recovery-option. To preserve an existing postgresql.auto.conf, run restore with --type=preserve.

RHEL keeps postgresql.conf in the data directory by default. The last restore overwrote its changes, so enable hot_standby again. Alternatively, store postgresql.conf elsewhere or enable hot_standby on pg-primary, where it is ignored.

pg-standby:/var/lib/pgsql/14/data/postgresql.conf ⇒ Enable hot_standby

archive_command = 'pgbackrest --stanza=demo archive-push %p'
archive_mode = on
hot_standby = on
log_filename = 'postgresql.log'

pg-standby ⇒ Start PostgreSQL

sudo systemctl start postgresql-14.service

Check the PostgreSQL log to confirm that streaming replication started.

pg-standby ⇒ Examine the PostgreSQL log output for log messages indicating success

sudo -u postgres cat /var/lib/pgsql/14/data/log/postgresql.log
       [filtered 12 lines of output]
LOG:  database system is ready to accept read-only connections
LOG:  restored log file "000000070000000000000026" from archive

LOG:  started streaming WAL from primary at 0/27000000 on timeline 7

New tables on pg-primary now appear quickly on pg-standby without pg_switch_wal().

pg-primary ⇒ Create a new table on the primary

sudo -u postgres psql -c " \
       begin; \
       create table stream_table (message text); \
       insert into stream_table values ('Important Data'); \
       commit; \
       select *, current_timestamp from stream_table";
       [filtered 4 lines of output]
    message     |       current_timestamp
----------------+-------------------------------
 Important Data | 2026-09-27 10:13:26.824575+00

(1 row)

pg-standby ⇒ Query table on the standby

sudo -u postgres psql -c " \
       select *, current_timestamp from stream_table"
    message     |       current_timestamp
----------------+-------------------------------
 Important Data | 2026-09-27 10:13:27.012839+00

(1 row)

Multiple Stanzas

pgBackRest supports multiple stanzas, commonly with one shared repository host.

Installation

Create a host named pg-alt for the new primary.

Prefer package installation to a source build. Packages usually perform the remaining steps in this section. If a package omits a directory or sets incorrect permissions, create the directory or correct its permissions manually.

RHEL packages for pgBackRest are available at yum.postgresql.org.

If your distribution or version has no package, build from source and follow these manual installation steps.

pg-alt ⇒ Install dependencies

sudo yum install postgresql-libs libssh2

pg-alt ⇒ Copy pgBackRest binary from build host

sudo scp build:/build/pgbackrest/src/pgbackrest /usr/bin
sudo chmod 755 /usr/bin/pgbackrest

pgBackRest requires log and configuration directories and a configuration file.

pg-alt ⇒ Create pgBackRest configuration file and directories

sudo mkdir -p -m 770 /var/log/pgbackrest
sudo chown postgres:postgres /var/log/pgbackrest
sudo mkdir -p /etc/pgbackrest
sudo mkdir -p /etc/pgbackrest/conf.d
sudo touch /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf

Configuration

Use configuration similar to pg-primary, but select stanza demo-alt. This separates its backups and archive.

pg-alt:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pgBackRest on the new primary

[demo-alt]
pg1-path=/var/lib/pgsql/14/data
[global]
log-level-file=detail
repo1-host=repository
repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt
repo1-host-cert-file=/etc/pgbackrest/cert/client.crt
repo1-host-key-file=/etc/pgbackrest/cert/client.key
repo1-host-type=tls
tls-server-address=*
tls-server-auth=pgbackrest-client=demo-alt
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pg1-host/pg1-host-user and pg1-path

[demo]
pg1-host=pg-primary
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/14/data
[demo-alt]
pg1-host=pg-alt
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/14/data
[global]
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
tls-server-address=*
tls-server-auth=pgbackrest-client=*
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

pg-alt ⇒ Setup pgBackRest Server

sudo cat /etc/systemd/system/pgbackrest.service
[Unit]
Description=pgBackRest Server
After=network.target
StartLimitIntervalSec=0
[Service]
Type=notify
Restart=always
RestartSec=1
User=postgres
ExecStart=/usr/bin/pgbackrest server
ExecStartPost=/bin/sleep 3
ExecStartPost=/bin/bash -c "[ ! -z $MAINPID ]"
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
sudo systemctl enable pgbackrest
sudo systemctl start pgbackrest

Setup Demo Cluster

pg-alt ⇒ Create the demo cluster

sudo -u postgres /usr/pgsql-14/bin/initdb \
       -D /var/lib/pgsql/14/data -k -A peer

pg-alt:/var/lib/pgsql/14/data/postgresql.conf ⇒ Configure PostgreSQL settings

archive_command = 'pgbackrest --stanza=demo-alt archive-push %p'
archive_mode = on
log_filename = 'postgresql.log'

pg-alt ⇒ Start the demo cluster

sudo systemctl restart postgresql-14.service

Create the Stanza and Check Configuration

Run stanza-create to initialize the stanza. Then run check to verify archive and backup configuration.

pg-alt ⇒ Create the stanza and check the configuration

sudo -u postgres pgbackrest --stanza=demo-alt --log-level-console=info stanza-create
P00   INFO: stanza-create command begin 2.59.2: --exec-id=929-78f9f9d9 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --stanza=demo-alt
P00   INFO: stanza-create for stanza 'demo-alt' on repo1

P00   INFO: stanza-create command end: completed successfully
sudo -u postgres pgbackrest --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=962-8c30e5f5 --log-level-console=info --log-level-file=detail --no-log-timestamp --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls

P00   INFO: check stanza 'demo-alt'

P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 000000010000000000000001 successfully archived to '/var/lib/pgbackrest/archive/demo-alt/14-1/0000000100000000/000000010000000000000001-c14ec01d6a751eb028bfd43785eaa7a95637afeb.gz' on repo1

P00   INFO: check command end: completed successfully

Run check on the repository host to check all stanzas.

repository ⇒ Check the configuration for all stanzas

sudo -u pgbackrest pgbackrest --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=1381-a0734629 --log-level-console=info --no-log-timestamp --repo1-path=/var/lib/pgbackrest

P00   INFO: check stanza 'demo'

P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 000000070000000000000027 successfully archived to '/var/lib/pgbackrest/archive/demo/14-1/0000000700000000/000000070000000000000027-9f1c78df044b58a0ba45c2f0fa20f4a71347f90e.gz' on repo1
P00   INFO: check stanza 'demo-alt'

P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 000000010000000000000002 successfully archived to '/var/lib/pgbackrest/archive/demo-alt/14-1/0000000100000000/000000010000000000000002-3e7365ad946dd303f957dbf3c75889cac056df3a.gz' on repo1

P00   INFO: check command end: completed successfully

Asynchronous Archiving

Enable archive-async for asynchronous archive-push and archive-get.

Create a spool path for transient data. Each command uses it differently, as described in the following sections.

pg-primary ⇒ Create the spool directory

sudo mkdir -p -m 750 /var/spool/pgbackrest
sudo chown postgres:postgres /var/spool/pgbackrest

pg-standby ⇒ Create the spool directory

sudo mkdir -p -m 750 /var/spool/pgbackrest
sudo chown postgres:postgres /var/spool/pgbackrest

Configure the spool path and enable asynchronous archiving. This reduces remote-storage connections. Set process-max for parallel operations and further performance improvements. Keep it low enough to preserve normal database performance.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Configure the spool path and asynchronous archiving

[demo]
pg1-path=/var/lib/pgsql/14/data
[global]
archive-async=y
log-level-file=detail
repo1-host=repository
repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt
repo1-host-cert-file=/etc/pgbackrest/cert/client.crt
repo1-host-key-file=/etc/pgbackrest/cert/client.key
repo1-host-type=tls
spool-path=/var/spool/pgbackrest
tls-server-address=*
tls-server-auth=pgbackrest-client=demo
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key
[global:archive-get]
process-max=2
[global:archive-push]
process-max=2

pg-standby:/etc/pgbackrest/pgbackrest.conf ⇒ Configure the spool path and asynchronous archiving

[demo]
pg1-path=/var/lib/pgsql/14/data
recovery-option=primary_conninfo=host=172.17.0.6 port=5432 user=replicator
[global]
archive-async=y
log-level-file=detail
repo1-host=repository
repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt
repo1-host-cert-file=/etc/pgbackrest/cert/client.crt
repo1-host-key-file=/etc/pgbackrest/cert/client.key
repo1-host-type=tls
spool-path=/var/spool/pgbackrest
tls-server-address=*
tls-server-auth=pgbackrest-client=demo
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key
[global:archive-get]
process-max=2
[global:archive-push]
process-max=2

NOTE:

Set process-max in command-specific sections so it does not affect backup or restore. You can give archive-push and archive-get different values.

For this demonstration, interrupt streaming replication so PostgreSQL must fetch WAL through restore_command.

pg-primary ⇒ Break streaming replication by changing the replication password

sudo -u postgres psql -c "alter user replicator password 'bogus'"
ALTER ROLE

pg-standby ⇒ Restart standby to break connection

sudo systemctl restart postgresql-14.service

Archive Push

Asynchronous archive-push transfers WAL archiving to separate processes to improve throughput. It finds ready segments beyond the one PostgreSQL currently requests through archive_command. It copies WAL directly from pg_xlog/pg_wal to the archive. The archive_command returns success only after the requested segment is safely stored.

The spool path contains current WAL archive status. Status files are usually empty and use little I/O and space, at most a few MB. pgBackRest can recreate all this information. You do not need to preserve the directory when moving the cluster to new hardware.

IMPORTANT:

The original asynchronous implementation copied WAL to the spool directory before compression and transfer. The newer implementation reads WAL directly from pg_xlog. If you used asynchronous archiving in v1.12 or earlier, read the v1.13 release notes carefully before upgrading.

Monitor asynchronous activity in [stanza]-archive-push-async.log. To test it, push several WAL segments quickly.

pg-primary ⇒ Test parallel asynchronous archiving

sudo -u postgres psql -c " \
       select pg_create_restore_point('test async push'); select pg_switch_wal(); \
       select pg_create_restore_point('test async push'); select pg_switch_wal(); \
       select pg_create_restore_point('test async push'); select pg_switch_wal(); \
       select pg_create_restore_point('test async push'); select pg_switch_wal(); \
       select pg_create_restore_point('test async push'); select pg_switch_wal();"

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info check
P00   INFO: check command begin 2.59.2: --exec-id=6867-5d1ad560 --log-level-console=info --log-level-file=detail --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --stanza=demo
P00   INFO: check repo1 configuration (primary)
P00   INFO: check repo1 archive for WAL (primary)
P00   INFO: WAL segment 00000007000000000000002D successfully archived to '/var/lib/pgbackrest/archive/demo/14-1/0000000700000000/00000007000000000000002D-381cd9857b86d83a40d68c95c359635d8866fce8.gz' on repo1

P00   INFO: check command end: completed successfully

The log now shows parallel, asynchronous activity.

pg-primary ⇒ Check results in the log

sudo -u postgres cat /var/log/pgbackrest/demo-archive-push-async.log
-------------------PROCESS START-------------------
P00   INFO: archive-push:async command begin 2.59.2: [/var/lib/pgsql/14/data/pg_wal] --archive-async --exec-id=6831-8bd24b55 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo

P00   INFO: push 1 WAL file(s) to archive: 000000070000000000000028
P01 DETAIL: pushed WAL file '000000070000000000000028' to the archive

P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}}
P00   INFO: archive-push:async command end: completed successfully

-------------------PROCESS START-------------------
P00   INFO: archive-push:async command begin 2.59.2: [/var/lib/pgsql/14/data/pg_wal] --archive-async --exec-id=6869-a001e63b --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo

P00   INFO: push 5 WAL file(s) to archive: 000000070000000000000029...00000007000000000000002D
P02 DETAIL: pushed WAL file '00000007000000000000002A' to the archive
P01 DETAIL: pushed WAL file '000000070000000000000029' to the archive
P01 DETAIL: pushed WAL file '00000007000000000000002C' to the archive
P02 DETAIL: pushed WAL file '00000007000000000000002B' to the archive
P01 DETAIL: pushed WAL file '00000007000000000000002D' to the archive

P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}}
P00   INFO: archive-push:async command end: completed successfully

Archive Get

Asynchronous archive-get keeps a local WAL queue to improve throughput. If a requested segment is absent, it fetches that segment and enough consecutive segments to fill the queue. archive-get-queue-max controls maximum size. When the queue falls below half full, pgBackRest fetches more WAL to refill it.

Asynchronous operation helps most with high WAL volumes or high-latency repository connections, such as S3 and other object stores. For high latency, consider increasing process-max.

Monitor asynchronous activity in [stanza]-archive-get-async.log.

pg-standby ⇒ Check results in the log

sudo -u postgres cat /var/log/pgbackrest/demo-archive-get-async.log
-------------------PROCESS START-------------------
P00   INFO: archive-get:async command begin 2.59.2: [000000070000000000000024, 000000070000000000000025, 000000070000000000000026, 000000070000000000000027, 000000070000000000000028, 000000070000000000000029, 00000007000000000000002A, 00000007000000000000002B] --archive-async --exec-id=1951-19ef105e --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo
P00   INFO: get 8 WAL file(s) from archive: 000000070000000000000024...00000007000000000000002B
P01 DETAIL: found 000000070000000000000024 in the repo1: 14-1 archive

P02 DETAIL: found 000000070000000000000025 in the repo1: 14-1 archive
P01 DETAIL: found 000000070000000000000026 in the repo1: 14-1 archive
P02 DETAIL: found 000000070000000000000027 in the repo1: 14-1 archive

P00 DETAIL: unable to find 000000070000000000000028 in the archive
P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}}
       [filtered 24 lines of output]
P00   INFO: archive-get:async command begin 2.59.2: [000000070000000000000028, 000000070000000000000029, 00000007000000000000002A, 00000007000000000000002B, 00000007000000000000002C, 00000007000000000000002D, 00000007000000000000002E, 00000007000000000000002F] --archive-async --exec-id=2006-9db76252 --log-level-console=off --log-level-file=detail --log-level-stderr=off --no-log-timestamp --pg1-path=/var/lib/pgsql/14/data --process-max=2 --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --spool-path=/var/spool/pgbackrest --stanza=demo
P00   INFO: get 8 WAL file(s) from archive: 000000070000000000000028...00000007000000000000002F
P01 DETAIL: found 000000070000000000000028 in the repo1: 14-1 archive

P02 DETAIL: found 000000070000000000000029 in the repo1: 14-1 archive
P01 DETAIL: found 00000007000000000000002A in the repo1: 14-1 archive
P02 DETAIL: found 00000007000000000000002B in the repo1: 14-1 archive
P01 DETAIL: found 00000007000000000000002C in the repo1: 14-1 archive
P02 DETAIL: found 00000007000000000000002D in the repo1: 14-1 archive

P00 DETAIL: unable to find 00000007000000000000002E in the archive
P00 DETAIL: statistics: {"socket.client":{"total":1},"socket.session":{"total":1},"tls.client":{"total":1},"tls.session":{"total":1}}
       [filtered 7 lines of output]

pg-primary ⇒ Fix streaming replication by changing the replication password

sudo -u postgres psql -c "alter user replicator password 'jw8s0F4'"
ALTER ROLE

Backup from a Standby

pgBackRest can back up from a standby instead of the primary. Configure pg-standby and enable backup-standby. If several standbys are configured, it uses the first running standby found.

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Configure pg2-host/pg2-host-user and pg2-path

[demo]
pg1-host=pg-primary
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/14/data
pg2-host=pg-standby
pg2-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg2-host-cert-file=/etc/pgbackrest/cert/client.crt
pg2-host-key-file=/etc/pgbackrest/cert/client.key
pg2-host-type=tls
pg2-path=/var/lib/pgsql/14/data
[demo-alt]
pg1-host=pg-alt
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/14/data
[global]
backup-standby=y
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
tls-server-address=*
tls-server-auth=pgbackrest-client=*
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

Backup requires both the primary and standby databases. Most files come from the standby to reduce primary load. Configure hosts in any order. pgBackRest detects their roles automatically.

repository ⇒ Backup the demo cluster from pg2

sudo -u pgbackrest pgbackrest --stanza=demo --log-level-console=detail backup
       [filtered 2 lines of output]
P00   INFO: execute backup start: backup begins after the requested immediate checkpoint completes
P00   INFO: backup start archive = 00000007000000000000002F, lsn = 0/2F000028

P00   INFO: wait for replay on the standby to reach 0/2F000028
P00   INFO: replay on the standby reached 0/2F000028

P00   INFO: check archive for prior segment 00000007000000000000002E
P01 DETAIL: backup file pg-primary:/var/lib/pgsql/14/data/log/postgresql.log (10.9KB, 0.42%) checksum 8263e0278ee2e26fe6f13d42ebced767372e21f7
P01 DETAIL: backup file pg-primary:/var/lib/pgsql/14/data/global/pg_control (8KB, 0.73%) checksum 9e1c403b811877210e0d38b2da34710fa9f0743f
P01 DETAIL: backup file pg-primary:/var/lib/pgsql/14/data/pg_hba.conf (4.5KB, 0.90%) checksum cfa97af1dab1b130f0a921fa2d10d76fe0c5f630

P01 DETAIL: match file from prior backup pg-primary:/var/lib/pgsql/14/data/current_logfiles (26B, 0.91%) checksum 78a9f5c10960f0d91fcd313937469824861795a2
P01 DETAIL: match file from prior backup pg-primary:/var/lib/pgsql/14/data/pg_logical/replorigin_checkpoint (8B, 0.91%) checksum 347fc8f2df71bd4436e38bd1516ccd7ea0d46532
       [filtered 1263 lines of output]

This incremental backup copies most files from pg-standby and only a few from pg-primary.

A standby backup is identical to a primary backup. pgBackRest starts and stops the backup on pg-primary. It copies replicated files from pg-standby and the remaining files from pg-primary. Thus, the backup includes primary logs and statistics.


Upgrading PostgreSQL

Immediately after a PostgreSQL major version upgrade, update pg-path in all pgBackRest configurations to the new database location. Then run stanza-upgrade. It upgrades the stanza in every repository configured on the host. If the database is offline, use --no-online.

These steps outline a primary and standby upgrade to demonstrate pgBackRest reconfiguration. They are not a complete PostgreSQL upgrade guide. Take a backup before upgrading.

pg-primary ⇒ Stop old cluster

sudo systemctl stop postgresql-14.service

Stop the old standby cluster. You will restore it from the upgraded cluster.

pg-standby ⇒ Stop old cluster

sudo systemctl stop postgresql-14.service

Create the new cluster and upgrade it.

pg-primary ⇒ Create new cluster and perform the upgrade

sudo -u postgres /usr/pgsql-15/bin/initdb \
       -D /var/lib/pgsql/15/data -k -A peer

sudo -u postgres sh -c 'cd /var/lib/pgsql && \
       /usr/pgsql-15/bin/pg_upgrade \
       --old-bindir=/usr/pgsql-14/bin \
       --new-bindir=/usr/pgsql-15/bin \
       --old-datadir=/var/lib/pgsql/14/data \
       --new-datadir=/var/lib/pgsql/15/data \
       --old-options=" -c config_file=/var/lib/pgsql/14/data/postgresql.conf" \
       --new-options=" -c config_file=/var/lib/pgsql/15/data/postgresql.conf"'
       [filtered 41 lines of output]
Checking for extension updates                              ok

Upgrade Complete

----------------
Optimizer statistics are not transferred by pg_upgrade.
       [filtered 4 lines of output]

Configure the new cluster settings and port.

pg-primary:/var/lib/pgsql/15/data/postgresql.conf ⇒ Configure PostgreSQL

archive_command = 'pgbackrest --stanza=demo archive-push %p'
archive_mode = on
log_filename = 'postgresql.log'

Update pgBackRest configuration on every system to use the new cluster.

pg-primary:/etc/pgbackrest/pgbackrest.conf ⇒ Upgrade the pg1-path

[demo]
pg1-path=/var/lib/pgsql/15/data
[global]
archive-async=y
log-level-file=detail
repo1-host=repository
repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt
repo1-host-cert-file=/etc/pgbackrest/cert/client.crt
repo1-host-key-file=/etc/pgbackrest/cert/client.key
repo1-host-type=tls
spool-path=/var/spool/pgbackrest
tls-server-address=*
tls-server-auth=pgbackrest-client=demo
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key
[global:archive-get]
process-max=2
[global:archive-push]
process-max=2

pg-standby:/etc/pgbackrest/pgbackrest.conf ⇒ Upgrade the pg-path

[demo]
pg1-path=/var/lib/pgsql/15/data
recovery-option=primary_conninfo=host=172.17.0.6 port=5432 user=replicator
[global]
archive-async=y
log-level-file=detail
repo1-host=repository
repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt
repo1-host-cert-file=/etc/pgbackrest/cert/client.crt
repo1-host-key-file=/etc/pgbackrest/cert/client.key
repo1-host-type=tls
spool-path=/var/spool/pgbackrest
tls-server-address=*
tls-server-auth=pgbackrest-client=demo
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key
[global:archive-get]
process-max=2
[global:archive-push]
process-max=2

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Upgrade pg1-path and pg2-path, disable backup from standby

[demo]
pg1-host=pg-primary
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/15/data
pg2-host=pg-standby
pg2-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg2-host-cert-file=/etc/pgbackrest/cert/client.crt
pg2-host-key-file=/etc/pgbackrest/cert/client.key
pg2-host-type=tls
pg2-path=/var/lib/pgsql/15/data
[demo-alt]
pg1-host=pg-alt
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/14/data
[global]
backup-standby=n
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
tls-server-address=*
tls-server-auth=pgbackrest-client=*
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

pg-primary ⇒ Copy hba configuration

sudo cp /var/lib/pgsql/14/data/pg_hba.conf \
       /var/lib/pgsql/15/data/pg_hba.conf

Before starting the new cluster, run stanza-upgrade.

pg-primary ⇒ Upgrade the stanza

sudo -u postgres pgbackrest --stanza=demo --no-online \
       --log-level-console=info stanza-upgrade
P00   INFO: stanza-upgrade command begin 2.59.2: --exec-id=7457-16565fb6 --log-level-console=info --log-level-file=detail --no-log-timestamp --no-online --pg1-path=/var/lib/pgsql/15/data --repo1-host=repository --repo1-host-ca-file=/etc/pgbackrest/cert/ca.crt --repo1-host-cert-file=/etc/pgbackrest/cert/client.crt --repo1-host-key-file=/etc/pgbackrest/cert/client.key --repo1-host-type=tls --stanza=demo
P00   INFO: stanza-upgrade for stanza 'demo' on repo1

P00   INFO: stanza-upgrade command end: completed successfully

Start the new cluster and verify the installation.

pg-primary ⇒ Start new cluster

sudo systemctl start postgresql-15.service

Test configuration with check.

pg-primary ⇒ Check configuration

sudo systemctl status postgresql-15.service
sudo -u postgres pgbackrest --stanza=demo check

Remove the old cluster.

pg-primary ⇒ Remove old cluster

sudo rm -rf /var/lib/pgsql/14/data

Install the new PostgreSQL binaries on the standby and create the cluster.

pg-standby ⇒ Remove old cluster and create the new cluster

sudo rm -rf /var/lib/pgsql/14/data
sudo -u postgres mkdir -p -m 700 /usr/pgsql-15/bin

Run check on the repository host. The standby is stopped, so expect a warning. This verifies that the repository knows about the standby and has correct primary configuration.

repository ⇒ Check configuration

sudo -u pgbackrest pgbackrest --stanza=demo check
P00   WARN: unable to check pg2: [DbConnectError] raised from remote-0 tls protocol on 'pg-standby': unable to connect to 'dbname='postgres' port=5432': connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
                Is the server running locally and accepting connections on that socket?

Take a full backup of the new cluster, then restore the standby from it. Requests for incr or diff automatically change to full.

repository ⇒ Run a full backup

sudo -u pgbackrest pgbackrest --stanza=demo --type=full backup

pg-standby ⇒ Restore the demo standby cluster

sudo -u postgres pgbackrest --stanza=demo --type=standby restore

pg-standby ⇒ Start PostgreSQL and check the pgBackRest configuration

sudo systemctl start postgresql-15.service
sudo -u postgres pgbackrest --stanza=demo check

After restoring the standby, enable standby backups again.

repository:/etc/pgbackrest/pgbackrest.conf ⇒ Re-enable backup from standby

[demo]
pg1-host=pg-primary
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/15/data
pg2-host=pg-standby
pg2-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg2-host-cert-file=/etc/pgbackrest/cert/client.crt
pg2-host-key-file=/etc/pgbackrest/cert/client.key
pg2-host-type=tls
pg2-path=/var/lib/pgsql/15/data
[demo-alt]
pg1-host=pg-alt
pg1-host-ca-file=/etc/pgbackrest/cert/ca.crt
pg1-host-cert-file=/etc/pgbackrest/cert/client.crt
pg1-host-key-file=/etc/pgbackrest/cert/client.key
pg1-host-type=tls
pg1-path=/var/lib/pgsql/14/data
[global]
backup-standby=y
process-max=3
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
tls-server-address=*
tls-server-auth=pgbackrest-client=*
tls-server-ca-file=/etc/pgbackrest/cert/ca.crt
tls-server-cert-file=/etc/pgbackrest/cert/server.crt
tls-server-key-file=/etc/pgbackrest/cert/server.key

4 - Command Reference

pgBackRest command reference with all options for backup, restore, archive, and management operations.

Source: https://pgbackrest.org/command.html

Introduction

Commands execute pgBackRest functions. Each command page lists every applicable option, including options shared with other commands. The lists also include options that you can set in pgbackrest.conf.

Use the reset- prefix on the command line to reset a non-boolean option from pgbackrest.conf to its default. For example, use this feature to restore a backup directly on a repository host. Normally, pgBackRest detects the remote database host and reports an error because remote restores are not supported. Add --reset-pg1-host to ignore the remote database host and restore locally. You might also need --pg1-path to select a path other than the database host path.

Use the no- prefix on the command line to set a boolean option to false.

To set an option through an environment variable, add the PGBACKREST_ prefix. Convert the option name to uppercase and replace - with _. For example, pg1-path becomes PGBACKREST_PG1_PATH, and stanza becomes PGBACKREST_STANZA. Use configuration-file values for boolean options, such as PGBACKREST_COMPRESS="n"; reset-* variants are not permitted. For an option that accepts multiple values on the command line or in a configuration file, separate values with colons. For example, use PGBACKREST_DB_INCLUDE="db1:db2".

Command-line options override environment options. Environment options override configuration-file options.

See Configuration Introduction for information about option types.

Commands

CommandSummary
annotateAdd, modify, or remove backup annotations after the backup is created.
archive-getFetch archived WAL segments for restore, PITR, or replica recovery.
archive-pushAccept WAL segments from PostgreSQL and push them to configured repositories.
backupCreate backups to the target repository (defaults to highest priority repository).
checkValidate stanza backup/archive configuration and WAL archiving health.
expireExpire backups and archived WAL based on configured retention policies.
helpShow command and option help at general, command, or option level.
infoDisplay stanza and backup status/metadata in text or JSON format.
repo-getRead repository files (like cat) for administration, investigation, and testing.
repo-lsList repository files/paths (like ls) for administration, investigation, and testing.
restoreRestore from backup (latest by default) with optional point-in-time recovery.
serverRun the pgBackRest TLS server for remote host access without SSH.
server-pingPing a pgBackRest TLS server to verify it is accepting connections.
stanza-createCreate stanza metadata in all configured repositories.
stanza-deletePermanently remove all backups and archives for a stanza.
stanza-upgradeUpgrade stanza metadata after a PostgreSQL major version upgrade.
startRe-allow pgBackRest processes to run after a previous stop.
stopPrevent new pgBackRest processes and optionally force-stop running ones.
verifyVerify that backup and archive data in the repository is valid.
versionDisplay the installed pgBackRest version.

4.1 - Annotate Command (annotate)

Reference for pgBackRest annotate command options and behavior.

Source: pgBackRest Command Docs: annotate

Use annotate to add, change, or remove annotations after the backup command creates a backup.

Command Options

Backup Annotation Option (--annotation)

Annotate backup with user-defined key/value pairs.

Attach informative key/value pairs to the backup. Repeat this option to attach multiple annotations.

When --set specifies a backup, the info command includes its annotations in text output. JSON output always includes annotations.

example: --annotation=source="Sunday backup for website database"

Set Option (--set)

Backup set to annotate.

The backup set to annotate.

example: --set=20150131-153358F_20150131-153401I

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

4.2 - Archive Get Command (archive-get)

Reference for pgBackRest archive-get command options and behavior.

Source: pgBackRest Command Docs: archive-get

PostgreSQL uses this command to restore a backup or perform PITR. It can also use the command instead of streaming to keep a replica current. PostgreSQL needs WAL segments for recovery and replica maintenance.

With multiple repositories, pgBackRest searches for WAL in priority order, such as repo1, then repo2. Usually, give faster or cheaper storage higher priority. If --repo specifies a repository, pgBackRest searches only that repository.

During a restore, pgBackRest generates and configures the archive-get command for PostgreSQL. See the example in Point-in-Time Recovery.

Command Options

Asynchronous Archiving Option (--archive-async)

Push/get WAL segments asynchronously.

Enables asynchronous operation for the archive-push and archive-get commands.

Asynchronous operation can reuse connections and process work in parallel, which improves efficiency. See spool-path, archive-get-queue-max, and archive-push-queue-max for more information.

default: n
example: --archive-async

Maximum Archive Get Queue Size Option (--archive-get-queue-max)

Maximum size of the pgBackRest archive-get queue.

When archive-async is enabled, set the maximum archive-get queue size. pgBackRest stores the queue in spool-path to supply WAL to PostgreSQL faster.

default: 128MiB
allowed: [0B, 4PiB]
example: --archive-get-queue-max=1GiB

Retry Missing WAL Segment Option (--archive-missing-retry)

Retry missing WAL segment

In asynchronous mode, retry a WAL segment that archive-get previously reported as missing. This prevents reuse of spool-path notifications from an earlier restore. Such notifications could cause recovery to fail before consistency is reached.

Disable this option to help PostgreSQL reliably detect the end of archived WAL and switch to streaming from the primary. With retries enabled, a continuous flow of archived WAL keeps PostgreSQL reading the archive instead of switching to streaming.

Before you disable this option, make sure the stanza spool path is empty. The restore command empties it automatically if the spool path is configured at restore time. Otherwise, empty it yourself.

default: y
example: --no-archive-missing-retry

Archive Timeout Option (--archive-timeout)

Archive timeout.

Set the maximum wait, in seconds, for each WAL segment to reach the pgBackRest archive repository. The check and backup commands use this timeout while waiting for WAL segments necessary for backup consistency.

default: 1m
allowed: [100ms, 1d]
example: --archive-timeout=30

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

pgBackRest Command Option (--cmd)

pgBackRest command.

pgBackRest can generate a command string, for example when restore generates the restore_command setting. It uses the command that started the pgBackRest process unless you specify the cmd option.

CAUTION:

Wrapping the pgBackRest command may cause unpredictable behavior and is not recommended.

default: [path of executed pgbackrest binary]
example: --cmd=/var/lib/pgsql/bin/pgbackrest_wrapper.sh

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Process Maximum Option (--process-max)

Max processes to use for compress/transfer.

Each process compresses and transfers data to increase command speed. Do not set process-max so high that database performance decreases.

default: 1
allowed: [1, 999]
example: --process-max=4

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Spool Path Option (--spool-path)

Path where transient data is stored.

This path stores data for asynchronous archive-push and archive-get commands.

After it stores WAL in the archive, asynchronous archive-push writes an acknowledgement in the spool path. On failure, it writes an error. The foreground process can then notify PostgreSQL quickly. Acknowledgement files contain zero bytes on success and a few hundred bytes on error.

Asynchronous archive-get queues WAL in the spool path to supply it quickly when PostgreSQL requests it. Transfers are most efficient when the spool path uses the same filesystem as pg_xlog/pg_wal. However, do not put the spool path inside pg_xlog/pg_wal. This can cause problems for PostgreSQL utilities, such as pg_rewind.

Spool-path data can and should survive a reboot. However, loss of this data does not cause a problem. For archive-push, pgBackRest checks again that each WAL segment is safely archived. For archive-get, it rebuilds the queue.

Use a local Posix-compatible filesystem for the spool path. It is not intended for remote filesystems, such as NFS or CIFS.

default: /var/spool/pgbackrest
example: --spool-path=/backup/db/spool

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Target Time for Repository Option (--repo-target-time)

Target time for repository.

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

example: --repo-target-time=2024-08-08 12:12:12+00

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

Stanza Options

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: --pg1-path=/data/db

Deprecated Name: db-path

4.3 - Archive Push Command (archive-push)

Reference for pgBackRest archive-push command options and behavior.

Source: pgBackRest Command Docs: archive-push

This command accepts a WAL segment from PostgreSQL. It archives the segment in each repository defined by an indexed repo-path option. See Repository for configuration details. The archive-async value determines whether pgBackRest immediately archives the segment or stores it locally first. With multiple repositories, archive-push attempts to write to as many as possible.

Configure PostgreSQL to call archive-push. See the example in Configure Archiving.

Command Options

Asynchronous Archiving Option (--archive-async)

Push/get WAL segments asynchronously.

Enables asynchronous operation for the archive-push and archive-get commands.

Asynchronous operation can reuse connections and process work in parallel, which improves efficiency. See spool-path, archive-get-queue-max, and archive-push-queue-max for more information.

default: n
example: --archive-async

Check Archive Option (--archive-check)

Check that WAL segments are in the archive before backup completes.

Check that the WAL archive contains all segments necessary for backup consistency. Keep the default unless you use another archive method.

This option must be enabled if archive-copy is enabled.

default: y
example: --no-archive-check

Check Archive Mode Option (--archive-mode-check)

Check the PostgreSQL archive_mode setting.

Enabled by default, this option disallows PostgreSQL archive_mode=always.

A standby can push WAL segments with the same logical contents as primary segments but different checksums. Disable archiving from multiple sources to avoid these conflicts.

CAUTION:

If you disable this option, make sure that only one archiver writes to the repository through archive-push.

default: y
example: --no-archive-mode-check

Archive Push Batch Size Option (--archive-push-batch-size)

Maximum amount of WAL to push per asynchronous run.

In asynchronous mode, each archive-push run processes all WAL segments that are ready. It checks archive-push-queue-max only at the start. A large run can let the queue grow far past the limit before the next check.

Set the amount of WAL to process per run. The process then exits, and the next archive-push starts it again and checks the queue. Lower values check the queue more often but start the asynchronous process more frequently. pgBackRest rounds the value down to a whole number of WAL segments. It always processes at least one segment.

default: 16GiB
allowed: [1MiB, 4PiB]
example: --archive-push-batch-size=1GiB

Maximum Archive Push Queue Size Option (--archive-push-queue-max)

Maximum size of the PostgreSQL archive queue.

When the queue reaches the limit:

  • pgBackRest tells PostgreSQL that it archived the WAL successfully, then DROPS IT.
  • PostgreSQL logs a warning.

This interrupts the archive log stream. PITR cannot continue past this point. Take a new backup to restore full recovery capability.

In asynchronous mode, pgBackRest drops the entire queue. This prevents brief WAL transfers before the queue exceeds the limit again.

In asynchronous mode, each archive-push run checks this limit only at the start. The queue can exceed it during the run. Reduce archive-push-batch-size to check more often.

This feature prevents WAL from filling the log volume, which would stop PostgreSQL completely. It sacrifices backup continuity to keep PostgreSQL running.

allowed: [0B, 4PiB]
example: --archive-push-queue-max=1TiB

Deprecated Name: archive-queue-max

Archive Timeout Option (--archive-timeout)

Archive timeout.

Set the maximum wait, in seconds, for each WAL segment to reach the pgBackRest archive repository. The check and backup commands use this timeout while waiting for WAL segments necessary for backup consistency.

default: 1m
allowed: [100ms, 1d]
example: --archive-timeout=30

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

pgBackRest Command Option (--cmd)

pgBackRest command.

pgBackRest can generate a command string, for example when restore generates the restore_command setting. It uses the command that started the pgBackRest process unless you specify the cmd option.

CAUTION:

Wrapping the pgBackRest command may cause unpredictable behavior and is not recommended.

default: [path of executed pgbackrest binary]
example: --cmd=/var/lib/pgsql/bin/pgbackrest_wrapper.sh

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Compress Option (--compress)

Use file compression.

Backup files are compatible with command-line compression tools.

This option is deprecated. Use compress-type instead.

default: y
example: --no-compress

Compress Level Option (--compress-level)

File compression level.

Set the file compression level when compress-type is not none or when compress=y (deprecated).

default (depending on compress-type):
    bz2 - 9
    gz - 6
    lz4 - 1
    zst - 3

allow range (depending on compress-type):
    bz2 - [1, 9]
    gz - [-1, 9]
    lz4 - [-5, 12]
    zst - [-7, 22]

example: --compress-level=9

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Compress Type Option (--compress-type)

File compression type.

The following compression types are supported:

  • none - no compression
  • bz2 - bzip2 compression format
  • gz - gzip compression format
  • lz4 - lz4 compression format (not available on all platforms)
  • zst - Zstandard compression format (not available on all platforms)
default: gz
example: --compress-type=none

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Process Maximum Option (--process-max)

Max processes to use for compress/transfer.

Each process compresses and transfers data to increase command speed. Do not set process-max so high that database performance decreases.

default: 1
allowed: [1, 999]
example: --process-max=4

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Spool Path Option (--spool-path)

Path where transient data is stored.

This path stores data for asynchronous archive-push and archive-get commands.

After it stores WAL in the archive, asynchronous archive-push writes an acknowledgement in the spool path. On failure, it writes an error. The foreground process can then notify PostgreSQL quickly. Acknowledgement files contain zero bytes on success and a few hundred bytes on error.

Asynchronous archive-get queues WAL in the spool path to supply it quickly when PostgreSQL requests it. Transfers are most efficient when the spool path uses the same filesystem as pg_xlog/pg_wal. However, do not put the spool path inside pg_xlog/pg_wal. This can cause problems for PostgreSQL utilities, such as pg_rewind.

Spool-path data can and should survive a reboot. However, loss of this data does not cause a problem. For archive-push, pgBackRest checks again that each WAL segment is safely archived. For archive-get, it rebuilds the queue.

Use a local Posix-compatible filesystem for the spool path. It is not intended for remote filesystems, such as NFS or CIFS.

default: /var/spool/pgbackrest
example: --spool-path=/backup/db/spool

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Check WAL Headers Option (--archive-header-check)

Check PostgreSQL version/id in WAL headers.

This option is enabled by default. It compares WAL headers with the PostgreSQL version and system identifier to check that WAL goes to the correct stanza. pgBackRest also checks pg_control against the stanza. It verifies that WAL comes from the PostgreSQL data directory that contains pg_control.

Thus, disabling this check is relatively safe. Disable it only when necessary, for example for encrypted WAL.

default: y
example: --no-archive-header-check

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

Stanza Options

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: --pg1-path=/data/db

Deprecated Name: db-path

4.4 - Backup Command (backup)

Reference for pgBackRest backup command options and behavior.

Source: pgBackRest Command Docs: backup

With multiple repositories, pgBackRest backs up to the highest priority repository, such as repo1. Use --repo to select another repository.

pgBackRest has no built-in scheduler. Use cron or another scheduler to run it.

See Perform a Backup for more details and examples.

Command Options

Backup Annotation Option (--annotation)

Annotate backup with user-defined key/value pairs.

Attach informative key/value pairs to the backup. Repeat this option to attach multiple annotations.

When --set specifies a backup, the info command includes its annotations in text output. JSON output always includes annotations.

example: --annotation=source="Sunday backup for website database"

Check Archive Option (--archive-check)

Check that WAL segments are in the archive before backup completes.

Check that the WAL archive contains all segments necessary for backup consistency. Keep the default unless you use another archive method.

This option must be enabled if archive-copy is enabled.

default: y
example: --no-archive-check

Copy Archive Option (--archive-copy)

Copy WAL segments needed for consistency to the backup.

Store WAL segments necessary for consistency directly in the backup. This protects against corruption in the WAL archive. The archive still stores these segments, so this option uses additional space.

When you use this option, give archive-push and backup the same compress-type, such as lz4. Otherwise, pgBackRest must recompress WAL segments with the backup compression type. This can require substantial processing when the backup generates a large amount of WAL.

After a restore, these WAL segments are in pg_xlog/pg_wal. PostgreSQL uses them before it calls restore_command.

The archive-check option must be enabled if archive-copy is enabled.

default: n
example: --archive-copy

Check Archive Mode Option (--archive-mode-check)

Check the PostgreSQL archive_mode setting.

Enabled by default, this option disallows PostgreSQL archive_mode=always.

A standby can push WAL segments with the same logical contents as primary segments but different checksums. Disable archiving from multiple sources to avoid these conflicts.

CAUTION:

If you disable this option, make sure that only one archiver writes to the repository through archive-push.

default: y
example: --no-archive-mode-check

Archive Timeout Option (--archive-timeout)

Archive timeout.

Set the maximum wait, in seconds, for each WAL segment to reach the pgBackRest archive repository. The check and backup commands use this timeout while waiting for WAL segments necessary for backup consistency.

default: 1m
allowed: [100ms, 1d]
example: --archive-timeout=30

Backup from Standby Option (--backup-standby)

Backup from the standby cluster.

Enable backups from the standby to reduce primary cluster load. Configure both the primary and standby hosts to use this option.

The following modes are supported:

  • y - Standby is required for backup.
  • prefer - Backup from standby if available otherwise backup from primary.
  • n - Backup from primary only.
default: n
example: --backup-standby=y

Page Checksums Option (--checksum-page)

Validate data page checksums.

Validate all data page checksums during a cluster backup. pgBackRest enables this option automatically when the cluster has data page checksums enabled.

Checksum validation failures do not stop a backup. pgBackRest writes warnings to the log and, with default settings, the console. It stores the invalid page list in the backup manifest.

example: --no-checksum-page

Path/File Exclusions Option (--exclude)

Exclude paths/files from the backup.

All exclusions are relative to $PGDATA. An exclusion ending in / excludes files in the directory but keeps the directory itself. For example, --exclude=junk/ excludes files in $PGDATA/junk. Without a final /, an exclusion matches either the exact file name or the name followed by /. For example, --exclude=junk excludes the $PGDATA/junk directory and all its files.

Use this feature with care. An excluded critical file can make the backup inconsistent. Test your restores.

pgBackRest logs each excluded file and its exclusion rule at info level. Review the list to make sure all exclusions are intended.

NOTE: Delta restores do not preserve exclusions. They remove files and directories that the backup excluded.

Do not use this option to exclude PostgreSQL logs. Use PostgreSQL log_directory to move logs outside PGDATA. This also preserves logs after a restore.

Specify multiple exclusions on the command line or in a configuration file.

example: --exclude=junk/

Expire Auto Option (--expire-auto)

Automatically run the expire command after a successful backup.

This setting is enabled by default. Disable it with care: pgBackRest then keeps all backups and archives indefinitely, which can fill the repository. Run expire regularly to prevent this.

Automatic expiration after a successful backup uses the backup command configuration. Options set only in an expire command section, such as [global:expire], do not apply. To use those options, disable automatic expiration and run expire separately.

default: y
example: --expire-auto

Force Option (--force)

Force an offline backup.

With --no-start-stop, pgBackRest runs a backup even if it detects that PostgreSQL is running. Use this option with extreme care. It will probably produce a bad backup.

A backup might still be useful in these conditions. For example, after a server crash, you might only be able to mount the cluster volume as read-only. A backup can then be useful even if postmaster.pid exists. Prefer to restore the previous backup and replay WAL. However, an unarchived WAL segment might contain a critical transaction.

default: n
example: --force

Manifest Save Threshold Option (--manifest-save-threshold)

Manifest save threshold during backup.

Set how often pgBackRest saves the manifest during a backup. The manifest stores checksums so that backup resume can work efficiently. The actual threshold is 1% of backup size or manifest-save-threshold, whichever is greater.

default: 1GiB
allowed: [1B, 1TiB]
example: --manifest-save-threshold=8GiB

Online Option (--online)

Perform an online backup.

Specify –no-online to prevent pgBackRest from calling the database cluster backup start/stop functions. Shut down PostgreSQL first. pgBackRest reports an error if PostgreSQL is running.

Use this option for offline backups. pgBackRest copies pg_xlog/pg_wal without changes and automatically disables archive-check for the backup.

default: y
example: --no-online

Resume Option (--resume)

Allow resume of failed backup.

Enable or disable backup resume. After a backup fails, resume can substantially reduce the time for another backup of the same type. This feature adds complexity. You can disable it in environments that do not need it.

default: y
example: --no-resume

Start Fast Option (--start-fast)

Force a checkpoint to start backup quickly.

Pass y to the backup start function fast parameter to force a checkpoint and start the backup immediately. Otherwise, the backup waits for the next regular checkpoint.

default: n
example: --start-fast

Type Option (--type)

Backup type.

The following backup types are supported:

  • full - Copy all database cluster files without dependencies on earlier backups.
  • incr - Create an incremental backup from the last successful backup.
  • diff - Create an incremental backup based on the last full backup.
default: incr
example: --type=full

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

pgBackRest Command Option (--cmd)

pgBackRest command.

pgBackRest can generate a command string, for example when restore generates the restore_command setting. It uses the command that started the pgBackRest process unless you specify the cmd option.

CAUTION:

Wrapping the pgBackRest command may cause unpredictable behavior and is not recommended.

default: [path of executed pgbackrest binary]
example: --cmd=/var/lib/pgsql/bin/pgbackrest_wrapper.sh

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Compress Option (--compress)

Use file compression.

Backup files are compatible with command-line compression tools.

This option is deprecated. Use compress-type instead.

default: y
example: --no-compress

Compress Level Option (--compress-level)

File compression level.

Set the file compression level when compress-type is not none or when compress=y (deprecated).

default (depending on compress-type):
    bz2 - 9
    gz - 6
    lz4 - 1
    zst - 3

allow range (depending on compress-type):
    bz2 - [1, 9]
    gz - [-1, 9]
    lz4 - [-5, 12]
    zst - [-7, 22]

example: --compress-level=9

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Compress Type Option (--compress-type)

File compression type.

The following compression types are supported:

  • none - no compression
  • bz2 - bzip2 compression format
  • gz - gzip compression format
  • lz4 - lz4 compression format (not available on all platforms)
  • zst - Zstandard compression format (not available on all platforms)
default: gz
example: --compress-type=none

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Database Timeout Option (--db-timeout)

Database query timeout.

Set the database query timeout in seconds. This includes backup start/stop functions, which can each take substantial time. Keep a high timeout unless these functions will return quickly. For example, you have set start-fast=y and know the cluster will generate few WAL segments during the backup.

NOTE: The db-timeout option must be less than the protocol-timeout option.

default: 30m
allowed: [100ms, 7d]
example: --db-timeout=600

Delta Option (--delta)

Restore or backup using checksums.

By default, a restore expects existing but empty PostgreSQL data and tablespace directories. Enable this option for a delta restore that uses checksums.

During a backup, use checksums instead of timestamps to determine which files to copy.

default: n
example: --delta

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Process Maximum Option (--process-max)

Max processes to use for compress/transfer.

Each process compresses and transfers data to increase command speed. Do not set process-max so high that database performance decreases.

default: 1
allowed: [1, 999]
example: --process-max=4

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Page Header Check Option (--page-header-check)

Check PostgreSQL page headers.

Enabled by default, this option adds page header checks.

Disable this option only when necessary, for example for encrypted pages.

default: y
example: --no-page-header-check

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Block Incremental Backup Option (--repo-block)

Enable block incremental backup.

Block incremental backup divides files into blocks that can be backed up independently. This saves repository space. It can also improve delta restore performance because pgBackRest can fetch individual blocks without reading the entire repository file.

NOTE: The repo-bundle option must be enabled before repo-block can be enabled.

File size and age determine block size. Older or larger files generally use larger blocks. Files above the age threshold do not use block incremental backup.

For maximum efficiency, enable block incremental for all backup types, including full backups. Full backups become slightly larger. Later differential and incremental backups use their block maps to save space.

default: n
example: --repo1-block

Repository Bundles Option (--repo-bundle)

Bundle files in repository.

Combine smaller files into bundles to reduce the number of repository files. Fewer file writes usually improve efficiency, especially with object stores such as S3. Zero-length files have only manifest entries and no stored file contents. This saves time and space.

default: n
example: --repo1-bundle

Repository Bundle Limit Option (--repo-bundle-limit)

Limit for file bundles.

Set the maximum file size for inclusion in bundles. Larger files are stored separately.

A resumed backup cannot reuse bundled files. Higher limits put more files in bundles and leave fewer files available for resume.

default: 2MiB
allowed: [8KiB, 1PiB]
example: --repo1-bundle-limit=10MiB

Repository Bundle Size Option (--repo-bundle-size)

Target size for file bundles.

Set the target size of one file bundle. The uncompressed bundle can be as large as repo-bundle-size + repo-bundle-limit. Do not set this option to the maximum file size your filesystem permits.

Avoid very large bundles. A retry must repeat the entire bundle.

default: 20MiB
allowed: [1MiB, 1PiB]
example: --repo1-bundle-size=10MiB

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Hardlink files between backups in the repository.

Hard-link differential and incremental backup files to their full backups. Each backup then appears to be a full backup at the filesystem level. Use care: changes to hard-linked files can affect every backup in the set.

default: n
example: --repo1-hardlink

Deprecated Name: hardlink

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

Archive Retention Option (--repo-retention-archive)

Number of backups worth of continuous WAL to retain.

NOTE: WAL segments required to make a backup consistent are always retained until the backup is expired regardless of how this option is configured.

If this value is unset and repo-retention-full-type is count (the default), archive retention follows backup retention. When repo-retention-archive-type is full, it uses repo-retention-full. When the archive type is diff, it uses repo-retention-diff. Thus, WAL expires only for backups that have already expired. If repo-retention-full-type is time, the default removes archives older than the oldest full backup retained to satisfy repo-retention-full.

Set this option when repo-retention-archive-type is incr. With limited disk space, use it with repo-retention-archive-type to expire WAL segments more aggressively. However, backups with expired WAL cannot support PITR. This is not recommended.

allowed: [1, 9999999]
example: --repo1-retention-archive=2

Deprecated Name: retention-archive

Archive Retention Type Option (--repo-retention-archive-type)

Backup type for WAL retention.

When set to full, retain archive logs for the number of full backups specified by repo-retention-archive. When set to diff, count both full and differential backups. Thus, if the latest backup is full, it counts as a differential for repo-retention. When set to incr, count full, differential, and incremental backups. Prefer the default, which expires WAL only when full backups expire.

default: full
example: --repo1-retention-archive-type=diff

Deprecated Name: retention-archive-type

Differential Retention Option (--repo-retention-diff)

Number of differential backups to retain.

When a differential backup expires, its dependent incremental backups also expire. If this option is unset, differential backups remain until their parent full backups expire.

The differential backup count includes full backups. In most cases, this slightly reduces the number of differential backups retained.

allowed: [1, 9999999]
example: --repo1-retention-diff=3

Deprecated Name: retention-diff

Full Retention Option (--repo-retention-full)

Full backup retention count/time.

When a full backup expires, its dependent differential and incremental backups also expire. If this option is unset, pgBackRest reports a warning. For indefinite retention, use the maximum value.

allowed: [1, 9999999]
example: --repo1-retention-full=2

Deprecated Name: retention-full

Full Retention Type Option (--repo-retention-full-type)

Retention type for full backups.

Select whether repo-retention-full specifies a number of days or a count of full backups to keep.

With time, pgBackRest removes full backups older than repo-retention-full only if another retained backup is at least that old. For example, set repo-retention-full to 30 days with two full backups aged 25 and 35 days. Neither expires. Removing the 35-day backup would leave only the 25-day backup, which cannot satisfy the 30-day policy. Archived WAL older than the oldest remaining full backup expires automatically unless you explicitly set repo-retention-archive-type and repo-retention-archive.

With count, pgBackRest expires full backups that exceed repo-retention-full. For example, with repo-retention-full set to 4, completion of a fifth full backup expires the oldest, leaving 4.

Only successfully completed backups count toward retention. For example, set repo-retention-full-type to count and repo-retention-full to 2. The oldest full backup expires only after 3 full backups complete.

default: count
example: --repo1-retention-full-type=time

Backup History Retention Option (--repo-retention-history)

Days of backup history manifests to retain.

When a backup completes, pgBackRest copies its manifest to backup.history. By default, these files never expire. They support analysis, such as measurements of backup and WAL growth over time.

Set repo-retention-history to the number of days of backup history manifests to retain. History always includes unexpired backups. Set repo-retention-history=0 to keep history only for unexpired backups.

When a full backup history manifest expires, its dependent differential and incremental backup history manifests also expire.

allowed: [0, 9999999]
example: --repo1-retention-history=365

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Create symlinks within the repository.

Create latest and tablespace symlinks. These mainly help with snapshot-based, in-place repository recovery, which is uncommon.

Most users probably do not need this feature. It remains enabled by default for compatibility. Disable it for Posix-like storage that cannot support symlinks.

default: y
example: --no-repo1-symlink

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

Stanza Options

PostgreSQL Database Option (--pg-database)

PostgreSQL database.

Set the database name for PostgreSQL connections. The default is usually suitable, but some installations do not have this database.

For compatibility, pgBackRest ignores the PGDATABASE environment variable.

default: postgres
example: --pg1-database=backupdb

PostgreSQL Host Option (--pg-host)

PostgreSQL host for operating remotely.

Use this option when the PostgreSQL host and repository host differ.

example: --pg1-host=db.domain.com

Deprecated Name: db-host

PostgreSQL Host Certificate Authority File Option (--pg-host-ca-file)

PostgreSQL host certificate authority file.

Use a CA file other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

PostgreSQL Host Certificate Authority Path Option (--pg-host-ca-path)

PostgreSQL host certificate authority path.

Use a CA path other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-path=/etc/pki/tls/certs

PostgreSQL Host Certificate File Option (--pg-host-cert-file)

PostgreSQL host certificate file.

pgBackRest sends this certificate to the PostgreSQL host to prove the client identity.

example: --pg1-host-cert-file=/path/to/client.crt

PostgreSQL Host Command Option (--pg-host-cmd)

PostgreSQL host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and PostgreSQL hosts. Otherwise, the PostgreSQL host uses the local command path.

default: [path of executed pgbackrest binary]
example: --pg1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: db-cmd

PostgreSQL Host Configuration Option (--pg-host-config)

pgBackRest database host configuration file.

Set the PostgreSQL host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --pg1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: db-config

PostgreSQL Host Configuration Include Path Option (--pg-host-config-include-path)

pgBackRest database host configuration include path.

Set the PostgreSQL host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --pg1-host-config-include-path=/conf/pgbackrest/conf.d

PostgreSQL Host Configuration Path Option (--pg-host-config-path)

pgBackRest database host configuration path.

Set the PostgreSQL host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --pg1-host-config-path=/conf/pgbackrest

PostgreSQL Host Key File Option (--pg-host-key-file)

PostgreSQL host key file.

This key proves that the certificate owner sent the client certificate.

example: --pg1-host-key-file=/path/to/client.key

PostgreSQL Host Port Option (--pg-host-port)

PostgreSQL host port when pg-host is set.

Use this option to specify a non-default port for the PostgreSQL host protocol.

NOTE: When pg-host-type=ssh, pg-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on pg-host-type):
    tls - 8432

allowed: [0, 65535]
example: --pg1-host-port=25

Deprecated Name: db-ssh-port

PostgreSQL Host Protocol Type Option (--pg-host-type)

PostgreSQL host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --pg1-host-type=tls

PostgreSQL Host User Option (--pg-host-user)

PostgreSQL host logon user when pg-host is set.

This user owns the remote pgBackRest process and starts PostgreSQL connections. Use the PostgreSQL cluster owner, usually the default user postgres.

default: postgres
example: --pg1-host-user=db_owner

Deprecated Name: db-user

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: --pg1-path=/data/db

Deprecated Name: db-path

PostgreSQL Port Option (--pg-port)

PostgreSQL port.

Set the PostgreSQL port. Most clusters use the default port, so this setting is usually unnecessary.

default: 5432
allowed: [0, 65535]
example: --pg1-port=6543

Deprecated Name: db-port

PostgreSQL Socket Path Option (--pg-socket-path)

PostgreSQL unix socket path.

Set the Unix socket directory selected at PostgreSQL startup. pgBackRest searches the standard location for your OS automatically. Usually, set this option only if unix_socket_directories in postgresql.conf specifies another directory.

example: --pg1-socket-path=/var/run/postgresql

Deprecated Name: db-socket-path

PostgreSQL Database User Option (--pg-user)

PostgreSQL database user.

Set the database user for PostgreSQL connections. If unset, pgBackRest uses the local OS user or PGUSER.

example: --pg1-user=backupuser

4.5 - Check Command (check)

Reference for pgBackRest check command options and behavior.

Source: pgBackRest Command Docs: check

The check command validates pgBackRest and archive_command configuration for the specified stanza. It checks backup and archive settings for all repositories and databases configured on the current host. It detects configuration errors, especially archive errors that leave backups incomplete because required WAL segments never reached the archive. Run it on the PostgreSQL or repository host. You can also run it on a standby, but then it checks only repository configuration. A standby cannot execute pg_switch_xlog()/pg_switch_wal().

The command calls pg_create_restore_point('pgBackRest Archive Check') and pg_switch_xlog()/pg_switch_wal() to force PostgreSQL to archive a WAL segment.

Command Options

Check Archive Option (--archive-check)

Check that WAL segments are in the archive before backup completes.

Check that the WAL archive contains all segments necessary for backup consistency. Keep the default unless you use another archive method.

This option must be enabled if archive-copy is enabled.

default: y
example: --no-archive-check

Check Archive Mode Option (--archive-mode-check)

Check the PostgreSQL archive_mode setting.

Enabled by default, this option disallows PostgreSQL archive_mode=always.

A standby can push WAL segments with the same logical contents as primary segments but different checksums. Disable archiving from multiple sources to avoid these conflicts.

CAUTION:

If you disable this option, make sure that only one archiver writes to the repository through archive-push.

default: y
example: --no-archive-mode-check

Archive Timeout Option (--archive-timeout)

Archive timeout.

Set the maximum wait, in seconds, for each WAL segment to reach the pgBackRest archive repository. The check and backup commands use this timeout while waiting for WAL segments necessary for backup consistency.

default: 1m
allowed: [100ms, 1d]
example: --archive-timeout=30

Backup from Standby Option (--backup-standby)

Backup from the standby cluster.

Enable backups from the standby to reduce primary cluster load. Configure both the primary and standby hosts to use this option.

The following modes are supported:

  • y - Standby is required for backup.
  • prefer - Backup from standby if available otherwise backup from primary.
  • n - Backup from primary only.
default: n
example: --backup-standby=y

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Database Timeout Option (--db-timeout)

Database query timeout.

Set the database query timeout in seconds. This includes backup start/stop functions, which can each take substantial time. Keep a high timeout unless these functions will return quickly. For example, you have set start-fast=y and know the cluster will generate few WAL segments during the backup.

NOTE: The db-timeout option must be less than the protocol-timeout option.

default: 30m
allowed: [100ms, 7d]
example: --db-timeout=600

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

Stanza Options

PostgreSQL Database Option (--pg-database)

PostgreSQL database.

Set the database name for PostgreSQL connections. The default is usually suitable, but some installations do not have this database.

For compatibility, pgBackRest ignores the PGDATABASE environment variable.

default: postgres
example: --pg1-database=backupdb

PostgreSQL Host Option (--pg-host)

PostgreSQL host for operating remotely.

Use this option when the PostgreSQL host and repository host differ.

example: --pg1-host=db.domain.com

Deprecated Name: db-host

PostgreSQL Host Certificate Authority File Option (--pg-host-ca-file)

PostgreSQL host certificate authority file.

Use a CA file other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

PostgreSQL Host Certificate Authority Path Option (--pg-host-ca-path)

PostgreSQL host certificate authority path.

Use a CA path other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-path=/etc/pki/tls/certs

PostgreSQL Host Certificate File Option (--pg-host-cert-file)

PostgreSQL host certificate file.

pgBackRest sends this certificate to the PostgreSQL host to prove the client identity.

example: --pg1-host-cert-file=/path/to/client.crt

PostgreSQL Host Command Option (--pg-host-cmd)

PostgreSQL host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and PostgreSQL hosts. Otherwise, the PostgreSQL host uses the local command path.

default: [path of executed pgbackrest binary]
example: --pg1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: db-cmd

PostgreSQL Host Configuration Option (--pg-host-config)

pgBackRest database host configuration file.

Set the PostgreSQL host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --pg1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: db-config

PostgreSQL Host Configuration Include Path Option (--pg-host-config-include-path)

pgBackRest database host configuration include path.

Set the PostgreSQL host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --pg1-host-config-include-path=/conf/pgbackrest/conf.d

PostgreSQL Host Configuration Path Option (--pg-host-config-path)

pgBackRest database host configuration path.

Set the PostgreSQL host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --pg1-host-config-path=/conf/pgbackrest

PostgreSQL Host Key File Option (--pg-host-key-file)

PostgreSQL host key file.

This key proves that the certificate owner sent the client certificate.

example: --pg1-host-key-file=/path/to/client.key

PostgreSQL Host Port Option (--pg-host-port)

PostgreSQL host port when pg-host is set.

Use this option to specify a non-default port for the PostgreSQL host protocol.

NOTE: When pg-host-type=ssh, pg-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on pg-host-type):
    tls - 8432

allowed: [0, 65535]
example: --pg1-host-port=25

Deprecated Name: db-ssh-port

PostgreSQL Host Protocol Type Option (--pg-host-type)

PostgreSQL host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --pg1-host-type=tls

PostgreSQL Host User Option (--pg-host-user)

PostgreSQL host logon user when pg-host is set.

This user owns the remote pgBackRest process and starts PostgreSQL connections. Use the PostgreSQL cluster owner, usually the default user postgres.

default: postgres
example: --pg1-host-user=db_owner

Deprecated Name: db-user

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: --pg1-path=/data/db

Deprecated Name: db-path

PostgreSQL Port Option (--pg-port)

PostgreSQL port.

Set the PostgreSQL port. Most clusters use the default port, so this setting is usually unnecessary.

default: 5432
allowed: [0, 65535]
example: --pg1-port=6543

Deprecated Name: db-port

PostgreSQL Socket Path Option (--pg-socket-path)

PostgreSQL unix socket path.

Set the Unix socket directory selected at PostgreSQL startup. pgBackRest searches the standard location for your OS automatically. Usually, set this option only if unix_socket_directories in postgresql.conf specifies another directory.

example: --pg1-socket-path=/var/run/postgresql

Deprecated Name: db-socket-path

PostgreSQL Database User Option (--pg-user)

PostgreSQL database user.

Set the database user for PostgreSQL connections. If unset, pgBackRest uses the local OS user or PGUSER.

example: --pg1-user=backupuser

4.6 - Expire Command (expire)

Reference for pgBackRest expire command options and behavior.

Source: pgBackRest Command Docs: expire

pgBackRest rotates full backups according to a count or time period. Count-based retention keeps a specified number of backups, regardless of their creation times. Differential retention uses a count, but a differential always expires with its parent full backup. Incremental backups have no independent expiration policy. They expire with their parent full or differential backup. See Full Backup Retention and Differential Backup Retention for details and examples.

By default, pgBackRest keeps archived WAL for unexpired backups. You can change this per repository with retention-archive options, but this is not recommended. See Archive Retention for details and examples.

The expire command runs automatically after each successful backup. You can also run it manually. A manual run applies each configured repository’s retention settings; --repo limits it to one repository. Use --set to expire a specific backup set. Without --repo, pgBackRest searches all repositories and expires sets that match. Every expire run also checks and applies archive retention.

Command Options

Expire Archive Before Option (--archive-expire-before)

Remove WAL archive earlier than the specified WAL segment.

Remove WAL segments before the specified segment only when retained backups do not need them. This includes segments older than the earliest retained backup, or any earlier segment if the repository has no backups. Keep the specified segment and all later segments. The value corresponds to PostgreSQL archive_cleanup_command %r.

This option mainly supports archive-only repositories without backups. It can also remove WAL older than the first backup before full retention requirements permit normal archive expiration.

example: --archive-expire-before=000000010000000000000010

Oldest Option (--oldest)

Expire the oldest eligible backup set.

Expire the oldest full backup set that leaves at least one newer full backup. This automatically calculates the equivalent of decreasing retention by one. All differential and incremental backups that depend on that full backup also expire.

This option temporarily adjusts archive retention so that the same run can remove WAL for the expired backups.

With time-based full retention (--repo-retention-full-type=time), --oldest uses count-based expiration for this run.

WARNING:

This option cannot be combined with --set.

default: n
example: --oldest

Set Option (--set)

Backup set to expire.

Expire the specified backup label and all its dependent backups, regardless of retention rules. At least one full backup must remain in the repository.

WARNING:

Use this option with extreme care. It permanently removes the specified backup set and archived WAL not needed for backup consistency from the pgBackRest repository. This can prevent PITR. If --repo-retention-full or --repo-retention-archive is configured, override it with the maximum value during manual expiration. This helps prevent unintended archive expiration.

example: --set=20150131-153358F_20150131-153401I

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Dry Run Option (--dry-run)

Execute a dry-run for the command.

Use the command-line-only --dry-run option to show the changes a command would make without applying them.

default: n
example: --dry-run

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

Archive Retention Option (--repo-retention-archive)

Number of backups worth of continuous WAL to retain.

NOTE: WAL segments required to make a backup consistent are always retained until the backup is expired regardless of how this option is configured.

If this value is unset and repo-retention-full-type is count (the default), archive retention follows backup retention. When repo-retention-archive-type is full, it uses repo-retention-full. When the archive type is diff, it uses repo-retention-diff. Thus, WAL expires only for backups that have already expired. If repo-retention-full-type is time, the default removes archives older than the oldest full backup retained to satisfy repo-retention-full.

Set this option when repo-retention-archive-type is incr. With limited disk space, use it with repo-retention-archive-type to expire WAL segments more aggressively. However, backups with expired WAL cannot support PITR. This is not recommended.

allowed: [1, 9999999]
example: --repo1-retention-archive=2

Deprecated Name: retention-archive

Archive Retention Type Option (--repo-retention-archive-type)

Backup type for WAL retention.

When set to full, retain archive logs for the number of full backups specified by repo-retention-archive. When set to diff, count both full and differential backups. Thus, if the latest backup is full, it counts as a differential for repo-retention. When set to incr, count full, differential, and incremental backups. Prefer the default, which expires WAL only when full backups expire.

default: full
example: --repo1-retention-archive-type=diff

Deprecated Name: retention-archive-type

Differential Retention Option (--repo-retention-diff)

Number of differential backups to retain.

When a differential backup expires, its dependent incremental backups also expire. If this option is unset, differential backups remain until their parent full backups expire.

The differential backup count includes full backups. In most cases, this slightly reduces the number of differential backups retained.

allowed: [1, 9999999]
example: --repo1-retention-diff=3

Deprecated Name: retention-diff

Full Retention Option (--repo-retention-full)

Full backup retention count/time.

When a full backup expires, its dependent differential and incremental backups also expire. If this option is unset, pgBackRest reports a warning. For indefinite retention, use the maximum value.

allowed: [1, 9999999]
example: --repo1-retention-full=2

Deprecated Name: retention-full

Full Retention Type Option (--repo-retention-full-type)

Retention type for full backups.

Select whether repo-retention-full specifies a number of days or a count of full backups to keep.

With time, pgBackRest removes full backups older than repo-retention-full only if another retained backup is at least that old. For example, set repo-retention-full to 30 days with two full backups aged 25 and 35 days. Neither expires. Removing the 35-day backup would leave only the 25-day backup, which cannot satisfy the 30-day policy. Archived WAL older than the oldest remaining full backup expires automatically unless you explicitly set repo-retention-archive-type and repo-retention-archive.

With count, pgBackRest expires full backups that exceed repo-retention-full. For example, with repo-retention-full set to 4, completion of a fifth full backup expires the oldest, leaving 4.

Only successfully completed backups count toward retention. For example, set repo-retention-full-type to count and repo-retention-full to 2. The oldest full backup expires only after 3 full backups complete.

default: count
example: --repo1-retention-full-type=time

Backup History Retention Option (--repo-retention-history)

Days of backup history manifests to retain.

When a backup completes, pgBackRest copies its manifest to backup.history. By default, these files never expire. They support analysis, such as measurements of backup and WAL growth over time.

Set repo-retention-history to the number of days of backup history manifests to retain. History always includes unexpired backups. Set repo-retention-history=0 to keep history only for unexpired backups.

When a full backup history manifest expires, its dependent differential and incremental backup history manifests also expire.

allowed: [0, 9999999]
example: --repo1-retention-history=365

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Create symlinks within the repository.

Create latest and tablespace symlinks. These mainly help with snapshot-based, in-place repository recovery, which is uncommon.

Most users probably do not need this feature. It remains enabled by default for compatibility. Disable it for Posix-like storage that cannot support symlinks.

default: y
example: --no-repo1-symlink

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

4.7 - Help Command (help)

Reference for pgBackRest help command options and behavior.

Source: pgBackRest Command Docs: help

Help has three levels. With no command, pgBackRest shows general help. With a command, such as pgbackrest help backup, it shows the command description and valid options. Add an option, such as pgbackrest help backup type, to show its full description for that command.

Command Options

Display Help Option (--help)

Display help.

Show help even without the help command. This overrides --version.

default: n
example: --help

Display Version Option (--version)

Display version.

Show the version even without the version or help command.

default: n
example: --version

4.8 - Info Command (info)

Reference for pgBackRest info command options and behavior.

Source: pgBackRest Command Docs: info

The info command reports on one stanza or all stanzas. By default, text output summarizes backups for the requested stanzas. The text format can change in any release.

For machine-readable output, use --output=json. JSON includes much more information than text output. Its format stays stable unless a bug requires a change.

Use --detail-level=progress to show only progress and reduce execution time. This skips all checks except stanza availability.

Each stanza has a separate section. Use --stanza to show only one. The status field indicates stanza health: ok means pgBackRest operates normally. With multiple repositories, mixed means at least one repository has an unhealthy stanza; output then gives the status per repository. An unknown repository error uses the code other and includes full error details.

The wal archive min/max field shows the minimum and maximum archived WAL. With multiple repositories, it covers all repositories unless you set --repo. Archive retention policies or other causes can leave gaps in this range.

The backup/expire running and/or restore running messages appear beside status when those commands run on the host. Text output also shows progress per repository. JSON output includes a repo array.

Backups appear from oldest to newest. The oldest is always a full backup, with an F at the end of its label. The newest can be full, differential (label ends with D), or incremental (label ends with I).

The timestamp start/stop field shows when the backup ran. Use timestamp stop to choose a backup for Point-In-Time Recovery. See Point-In-Time Recovery for details.

The wal start/stop field shows the WAL range necessary for database consistency after a restore. The backup command checks that the archive contains this range before it completes.

The database size field shows the full, uncompressed database size. The database backup size field shows the database data actually backed up. These values match for full backups.

The repo field identifies the repository that contains the backup. The backup set size includes files in this backup and referenced backups needed for a restore. The backup size includes only files in this backup. These sizes match for full backups. When pgBackRest compression is enabled, repository sizes reflect compressed files.

The backup reference total summarizes other backups needed to restore this backup. Use --set for the complete reference list.

Command Options

Detail level Option (--detail-level)

Output detail level.

The following levels are supported:

  • progress - Output only the current backup/expire progress. This level cannot be used with the --set option.
  • full - Output full info.
default: full
example: --detail-level=progress

Output Option (--output)

Output format.

The following output types are supported:

  • text - Human-readable summary of backup information.
  • json - Exhaustive machine-readable backup information in JSON format.
default: text
example: --output=json

Set Option (--set)

Backup set to detail.

Details include all additional backups needed for a restore. They also list databases and OIDs, except template databases. Tablespace details include OIDs and default restore destinations. Symlink details show restore destinations when --link-all is specified.

example: --set=20150131-153358F_20150131-153401I

Type Option (--type)

Filter on backup type.

Filter the output using one of the following backup types:

  • full - Output only full backups.
  • diff - Output only differential backups.
  • incr - Output only incremental backups.
example: --type=full

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Target Time for Repository Option (--repo-target-time)

Target time for repository.

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

example: --repo-target-time=2024-08-08 12:12:12+00

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

4.9 - Repository Get Command (repo-get)

Reference for pgBackRest repo-get command options and behavior.

Source: pgBackRest Command Docs: repo-get

This command works like Unix cat on any supported repository type. Supply a fully qualified file name. It mainly supports administration, investigation, and testing. A normal pgBackRest setup does not require it.

For an encrypted repository, repo-get decrypts the file automatically. It does not decompress files. Pipe the output through the appropriate decompression command, such as gzip -d.

With multiple repositories, this command uses the highest priority repository, such as repo1. Use --repo to select another repository.

Command Options

Ignore Missing Option (--ignore-missing)

Ignore missing source file.

If the source file is missing, exit with status 1 without reporting an error.

default: n
example: --ignore-missing

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Raw Data Option (--raw)

Do not transform data.

Do not transform data, such as through encryption or decompression, for this command.

default: n
example: --raw

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Target Time for Repository Option (--repo-target-time)

Target time for repository.

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

example: --repo-target-time=2024-08-08 12:12:12+00

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

4.10 - Repository List Command (repo-ls)

Reference for pgBackRest repo-ls command options and behavior.

Source: pgBackRest Command Docs: repo-ls

This command works like Unix ls on any supported repository type. Supply an absolute path or a path relative to --repo-path. It mainly supports administration, investigation, and testing. A normal pgBackRest setup does not require it.

Default text output prints one file name per line. Use --output=json for JSON output.

With multiple repositories, this command uses the highest priority repository, such as repo1. Use --repo to select another repository.

Command Options

Filter Output Option (--filter)

Filter output with a regular expression.

Apply the filter to file and path names before output.

example: --filter="(F|D|I)$"

Output Option (--output)

Output format.

The following output types are supported:

  • text - Simple list with one file/link/path name on each line.
  • json - Detailed file/link/path information in JSON format.

In JSON format the available fields are:

  • name - file/link/path name (and partial path when recursing).
  • type - file, path, or link.
  • size - size in bytes (files only).
  • time - time last modified (files only).
  • destination - link destination (links only).
default: text
example: --output=json

Recurse Subpaths Option (--recurse)

Include all subpaths in output.

Include every subpath and its files in the output.

default: n
example: --recurse

Sort Output Option (--sort)

Sort output ascending, descending, or none.

The following sort types are supported:

  • asc - sort ascending.
  • desc - sort descending.
  • none - no sorting.
default: asc
example: --sort=desc

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Target Time for Repository Option (--repo-target-time)

Target time for repository.

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

example: --repo-target-time=2024-08-08 12:12:12+00

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

4.11 - Restore Command (restore)

Reference for pgBackRest restore command options and behavior.

Source: pgBackRest Command Docs: restore

By default, restore selects the latest backup from the first repository that has backups. See Quick Start - Restore a Backup. The repository order comes from pgbackrest.conf; for example, repo1 precedes repo2. Use --repo, such as --repo=1, to select a repository. Use --set to select a backup other than the latest.

For PITR with --type=time or --type=lsn, specify the target time or LSN with --target. Without --set, pgBackRest searches configured repositories in order for a backup containing the requested time or LSN. If none matches, --type=time uses the latest backup in the first repository that has backups. For --type=lsn, it selects no backup. For other PITR types, such as xid, use --set if the target precedes the latest backup. See Point-in-Time Recovery for details and examples.

Backups exclude replication slots, as PostgreSQL recommends. See Backing Up The Data Directory.

Command Options

Archive Mode Option (--archive-mode)

Preserve or disable archiving on restored cluster.

Preserve or disable archiving on the restored cluster. Disable it when you must promote the cluster for work but it will not become the new primary. In that case, the cluster should not push WAL to the repository.

The following modes are supported:

  • off - disable archiving by setting archive_mode=off.
  • preserve - preserve current archive_mode setting.

NOTE: This option is not available on PostgreSQL < 12.

default: preserve
example: --archive-mode=off

Exclude Database Option (--db-exclude)

Restore excluding the specified databases.

Restore excluded databases as sparse, zeroed files. This saves space while allowing PostgreSQL recovery. After recovery, you cannot access these databases, but you can remove them with drop database. Repeat --db-exclude to exclude multiple databases.

When combined with --db-include, --db-exclude applies only to the standard system databases: template0, template1, and postgres.

example: --db-exclude=db_main

Include Database Option (--db-include)

Restore only specified databases.

Restore only selected databases. Restore other databases as sparse, zeroed files to save space while allowing PostgreSQL recovery. After recovery, you cannot access the other databases, but you can remove them with drop database.

NOTE: built-in databases (template0, template1, and postgres) are always restored unless specifically excluded.

Repeat --db-include to include multiple databases.

See Restore Selected Databases for additional information and caveats.

example: --db-include=db_main

Force Option (--force)

Force a restore.

Used alone, this option completely overwrites PostgreSQL data and tablespace paths. With --delta, it uses timestamps and sizes instead of checksums for the delta restore.

default: n
example: --force

Restore all symlinks.

By default, restore converts symlinks to regular files and directories in $PGDATA. Original symlink destinations might be unsafe on a different system. Enable this option to restore all symlinks as they were on the backup source system.

default: n
example: --link-all

Modify the destination of a symlink.

Change a symlink destination file or path during a restore. Use this when the destination system has a different storage layout from the backup source.

example: --link-map=pg_xlog=/data/xlog

Recovery Option (--recovery-option)

Set an option in postgresql.auto.conf or recovery.conf.

See Server Configuration for postgresql.auto.conf and recovery.conf options. Select your PostgreSQL version. You can repeat this option.

For PostgreSQL >= 12, pgBackRest writes options to postgresql.auto.conf. For earlier versions, it writes them to recovery.conf.

NOTE: pgBackRest generates restore_command automatically. This option can override it, but use care because pgBackRest manages it for you. pgBackRest also generates target recovery options, such as recovery_target_name and recovery_target_time. Do not set those options here.

pgBackRest does not start PostgreSQL after it writes postgresql.auto.conf or recovery.conf. You can check or edit the file before you restart PostgreSQL manually.

example: --recovery-option=primary_conninfo=db.mydomain.com

Set Option (--set)

Backup set to restore.

Set the backup to restore. Use latest for the latest backup, or specify a backup name.

default: latest
example: --set=20150131-153358F_20150131-153401I

Tablespace Map Option (--tablespace-map)

Restore a tablespace into the specified directory.

Move a tablespace during restore. Use this when a replica has different tablespace locations or an upgraded system has different mount points.

pg_tablespace does not store tablespace locations, so you can move tablespaces freely. However, do not move a tablespace to data_directory; this can cause problems. For more information, see http://www.databasesoup.com/2013/11/moving-tablespaces.html.

example: --tablespace-map=ts_01=/db/ts_01

Map All Tablespaces Option (--tablespace-map-all)

Restore all tablespaces into the specified directory.

By default, tablespaces return to their original locations. Use tablespace-map to change individual locations, or this option to move all tablespaces to one new directory. This helps with development or staging systems whose storage layout differs from the backup source.

Use the specified path as the parent directory for all restored tablespaces.

CAUTION:

pgBackRest cannot map tablespaces created after the backup starts. If you need mapping, take a new backup after creating a tablespace.

example: --tablespace-map-all=/data/tablespace

Target Option (--target)

Recovery target.

Set the recovery target for --type values lsn, name, xid, or time. If the target precedes the latest backup, use --set unless the type is time or lsn.

example: --target=2015-01-30 14:15:11 EST

Target Action Option (--target-action)

Action to take when recovery target is reached.

With hot_standby=on, this option controls the cluster action at the target or the end of archived WAL. PostgreSQL 10 and later enable hot standby by default.

When hot_standby=off in PostgreSQL >= 12, pause acts like shutdown. When hot_standby=off in PostgreSQL < 12, pause acts like promote.

The following actions are supported:

  • pause - pause when recovery target is reached.
  • promote - promote and switch timeline when recovery target is reached.
  • shutdown - shutdown server when recovery target is reached. (PostgreSQL >= 9.5)
default: pause
example: --target-action=promote

Target Exclusive Option (--target-exclusive)

Stop just before the recovery target is reached.

Stop before the target instead of including it, which is the default. This applies only when --type is lsn, time, or xid. For example, --target-exclusive excludes transaction 1007 when --type=xid and --target=1007. See PostgreSQL recovery_target_inclusive documentation for details.

default: n
example: --no-target-exclusive

Target Timeline Option (--target-timeline)

Recover along a timeline.

See recovery_target_timeline in the PostgreSQL docs for more information.

example: --target-timeline=3

Type Option (--type)

Recovery type.

The following recovery types are supported:

  • default - Recover to the end of the archive stream.
  • immediate - Recover only until the database is consistent.
  • lsn - Recover to the LSN (Log Sequence Number) in --target. Requires PostgreSQL >= 10.
  • name - Recover to the restore point in --target.
  • xid - Recover to the transaction ID in --target.
  • time - Recover to the time in --target.
  • preserve - Preserve the existing postgresql.auto.conf or recovery.conf file.
  • standby - Add standby_mode=on to postgresql.auto.conf or recovery.conf to start the cluster in standby mode.
  • none - Do not write postgresql.auto.conf or recovery.conf. PostgreSQL attempts to reach consistency with WAL segments in pg_xlog/pg_wal. Supply the required segments or include them in the backup with archive-copy.

WARNING:

Avoid recovery with type=none. It does not increment the timeline after recovery. PostgreSQL might then try to archive duplicate WAL, which the archive rejects. This can fill the disk and cause a PostgreSQL panic. Tools such as pg_rewind might also fail or corrupt data.

Offline backups default to restore type of none because wal_level=minimal prevents Point-in-Time Recovery. pgBackRest respects an explicit type setting. Offline backups support Point-in-Time Recovery when wal_level > minimal.

default: default
example: --type=xid

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: y
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

pgBackRest Command Option (--cmd)

pgBackRest command.

pgBackRest can generate a command string, for example when restore generates the restore_command setting. It uses the command that started the pgBackRest process unless you specify the cmd option.

CAUTION:

Wrapping the pgBackRest command may cause unpredictable behavior and is not recommended.

default: [path of executed pgbackrest binary]
example: --cmd=/var/lib/pgsql/bin/pgbackrest_wrapper.sh

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Delta Option (--delta)

Restore or backup using checksums.

By default, a restore expects existing but empty PostgreSQL data and tablespace directories. Enable this option for a delta restore that uses checksums.

During a backup, use checksums instead of timestamps to determine which files to copy.

default: n
example: --delta

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Process Maximum Option (--process-max)

Max processes to use for compress/transfer.

Each process compresses and transfers data to increase command speed. Do not set process-max so high that database performance decreases.

default: 1
allowed: [1, 999]
example: --process-max=4

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Target Time for Repository Option (--repo-target-time)

Target time for repository.

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

example: --repo-target-time=2024-08-08 12:12:12+00

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

Stanza Options

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: --pg1-path=/data/db

Deprecated Name: db-path

4.12 - Server Command (server)

Reference for pgBackRest server command options and behavior.

Source: pgBackRest Command Docs: server

The pgBackRest server allows access to remote hosts without using the SSH protocol.

Command Options

TLS Server Address Option (--tls-server-address)

TLS server address.

Set the IP address on which the server accepts client requests.

default: localhost
example: --tls-server-address=*

TLS Server Authorized Clients Option (--tls-server-auth)

TLS server authorized clients.

The server verifies each client certificate. It also checks the certificate CN (Common Name) against the list configured with tls-server-auth.

To authorize a client CN for multiple stanzas, provide a comma-separated list to tls-server-auth. To authorize all stanzas, use tls-server-auth=client-cn=*. The client CN cannot contain wildcards.

example: --tls-server-auth=client-cn=stanza1,stanza2

TLS Server Certificate Authorities Option (--tls-server-ca-file)

TLS server certificate authorities.

Checks that client certificates are signed by a trusted certificate authority.

example: --tls-server-ca-file=/path/to/server.ca

TLS Server Certificate Option (--tls-server-cert-file)

TLS server certificate file.

The server sends this certificate to identify itself to the client.

example: --tls-server-cert-file=/path/to/server.crt

TLS Server Key Option (--tls-server-key-file)

TLS server key file.

This key proves that the certificate owner sent the server certificate.

example: --tls-server-key-file=/path/to/server.key

TLS Server Port Option (--tls-server-port)

TLS server port.

Set the port on which the server accepts client requests.

default: 8432
allowed: [1, 65535]
example: --tls-server-port=8000

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

4.13 - Server Ping Command (server-ping)

Reference for pgBackRest server-ping command options and behavior.

Source: pgBackRest Command Docs: server-ping

Ping a pgBackRest TLS server to check whether it accepts connections. This checks availability only; it does not attempt authentication.

If the command line does not specify a host, use tls-server-host.

Command Options

TLS Server Address Option (--tls-server-address)

TLS server address.

Set the IP address on which the server accepts client requests.

default: localhost
example: --tls-server-address=*

TLS Server Port Option (--tls-server-port)

TLS server port.

Set the port on which the server accepts client requests.

default: 8432
allowed: [1, 65535]
example: --tls-server-port=8000

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

4.14 - Stanza Create Command (stanza-create)

Reference for pgBackRest stanza-create command options and behavior.

Source: pgBackRest Command Docs: stanza-create

After configuring a stanza in pgbackrest.conf, run stanza-create. With multiple repositories, pgBackRest creates the stanza in each one. It skips existing stanzas, so you can safely repeat stanza-create, including after adding a repository.

See Create the Stanza for more information and an example.

Command Options

Online Option (--online)

Create on an online cluster.

Specify –no-online to create the stanza without connecting to PostgreSQL.

default: y
example: --no-online

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Database Timeout Option (--db-timeout)

Database query timeout.

Set the database query timeout in seconds. This includes backup start/stop functions, which can each take substantial time. Keep a high timeout unless these functions will return quickly. For example, you have set start-fast=y and know the cluster will generate few WAL segments during the backup.

NOTE: The db-timeout option must be less than the protocol-timeout option.

default: 30m
allowed: [100ms, 7d]
example: --db-timeout=600

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

Stanza Options

PostgreSQL Database Option (--pg-database)

PostgreSQL database.

Set the database name for PostgreSQL connections. The default is usually suitable, but some installations do not have this database.

For compatibility, pgBackRest ignores the PGDATABASE environment variable.

default: postgres
example: --pg1-database=backupdb

PostgreSQL Host Option (--pg-host)

PostgreSQL host for operating remotely.

Use this option when the PostgreSQL host and repository host differ.

example: --pg1-host=db.domain.com

Deprecated Name: db-host

PostgreSQL Host Certificate Authority File Option (--pg-host-ca-file)

PostgreSQL host certificate authority file.

Use a CA file other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

PostgreSQL Host Certificate Authority Path Option (--pg-host-ca-path)

PostgreSQL host certificate authority path.

Use a CA path other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-path=/etc/pki/tls/certs

PostgreSQL Host Certificate File Option (--pg-host-cert-file)

PostgreSQL host certificate file.

pgBackRest sends this certificate to the PostgreSQL host to prove the client identity.

example: --pg1-host-cert-file=/path/to/client.crt

PostgreSQL Host Command Option (--pg-host-cmd)

PostgreSQL host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and PostgreSQL hosts. Otherwise, the PostgreSQL host uses the local command path.

default: [path of executed pgbackrest binary]
example: --pg1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: db-cmd

PostgreSQL Host Configuration Option (--pg-host-config)

pgBackRest database host configuration file.

Set the PostgreSQL host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --pg1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: db-config

PostgreSQL Host Configuration Include Path Option (--pg-host-config-include-path)

pgBackRest database host configuration include path.

Set the PostgreSQL host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --pg1-host-config-include-path=/conf/pgbackrest/conf.d

PostgreSQL Host Configuration Path Option (--pg-host-config-path)

pgBackRest database host configuration path.

Set the PostgreSQL host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --pg1-host-config-path=/conf/pgbackrest

PostgreSQL Host Key File Option (--pg-host-key-file)

PostgreSQL host key file.

This key proves that the certificate owner sent the client certificate.

example: --pg1-host-key-file=/path/to/client.key

PostgreSQL Host Port Option (--pg-host-port)

PostgreSQL host port when pg-host is set.

Use this option to specify a non-default port for the PostgreSQL host protocol.

NOTE: When pg-host-type=ssh, pg-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on pg-host-type):
    tls - 8432

allowed: [0, 65535]
example: --pg1-host-port=25

Deprecated Name: db-ssh-port

PostgreSQL Host Protocol Type Option (--pg-host-type)

PostgreSQL host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --pg1-host-type=tls

PostgreSQL Host User Option (--pg-host-user)

PostgreSQL host logon user when pg-host is set.

This user owns the remote pgBackRest process and starts PostgreSQL connections. Use the PostgreSQL cluster owner, usually the default user postgres.

default: postgres
example: --pg1-host-user=db_owner

Deprecated Name: db-user

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: --pg1-path=/data/db

Deprecated Name: db-path

PostgreSQL Port Option (--pg-port)

PostgreSQL port.

Set the PostgreSQL port. Most clusters use the default port, so this setting is usually unnecessary.

default: 5432
allowed: [0, 65535]
example: --pg1-port=6543

Deprecated Name: db-port

PostgreSQL Socket Path Option (--pg-socket-path)

PostgreSQL unix socket path.

Set the Unix socket directory selected at PostgreSQL startup. pgBackRest searches the standard location for your OS automatically. Usually, set this option only if unix_socket_directories in postgresql.conf specifies another directory.

example: --pg1-socket-path=/var/run/postgresql

Deprecated Name: db-socket-path

PostgreSQL Database User Option (--pg-user)

PostgreSQL database user.

Set the database user for PostgreSQL connections. If unset, pgBackRest uses the local OS user or PGUSER.

example: --pg1-user=backupuser

4.15 - Stanza Delete Command (stanza-delete)

Reference for pgBackRest stanza-delete command options and behavior.

Source: pgBackRest Command Docs: stanza-delete

The stanza-delete command removes repository data for a stanza.

WARNING:

Use this command with care. It permanently removes every backup and archive for the specified stanza from the pgBackRest repository.

To delete a stanza:

  • Shut down the PostgreSQL cluster associated with the stanza (or use –force to override).
  • Run the stop command on the host where the stanza-delete command will be run.
  • Run the stanza-delete command.

After the command succeeds, remove the stanza from all applicable pgBackRest configuration files and environment variables.

Delete a stanza from one repository at a time. For multiple repositories, repeat stanza-delete with --repo for each repository.

Command Options

Force Option (--force)

Force stanza delete.

Use this option to delete the repository stanza even when its PostgreSQL cluster is running.

default: n
example: --no-force

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Database Timeout Option (--db-timeout)

Database query timeout.

Set the database query timeout in seconds. This includes backup start/stop functions, which can each take substantial time. Keep a high timeout unless these functions will return quickly. For example, you have set start-fast=y and know the cluster will generate few WAL segments during the backup.

NOTE: The db-timeout option must be less than the protocol-timeout option.

default: 30m
allowed: [100ms, 7d]
example: --db-timeout=600

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

Stanza Options

PostgreSQL Database Option (--pg-database)

PostgreSQL database.

Set the database name for PostgreSQL connections. The default is usually suitable, but some installations do not have this database.

For compatibility, pgBackRest ignores the PGDATABASE environment variable.

default: postgres
example: --pg1-database=backupdb

PostgreSQL Host Option (--pg-host)

PostgreSQL host for operating remotely.

Use this option when the PostgreSQL host and repository host differ.

example: --pg1-host=db.domain.com

Deprecated Name: db-host

PostgreSQL Host Certificate Authority File Option (--pg-host-ca-file)

PostgreSQL host certificate authority file.

Use a CA file other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

PostgreSQL Host Certificate Authority Path Option (--pg-host-ca-path)

PostgreSQL host certificate authority path.

Use a CA path other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-path=/etc/pki/tls/certs

PostgreSQL Host Certificate File Option (--pg-host-cert-file)

PostgreSQL host certificate file.

pgBackRest sends this certificate to the PostgreSQL host to prove the client identity.

example: --pg1-host-cert-file=/path/to/client.crt

PostgreSQL Host Command Option (--pg-host-cmd)

PostgreSQL host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and PostgreSQL hosts. Otherwise, the PostgreSQL host uses the local command path.

default: [path of executed pgbackrest binary]
example: --pg1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: db-cmd

PostgreSQL Host Configuration Option (--pg-host-config)

pgBackRest database host configuration file.

Set the PostgreSQL host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --pg1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: db-config

PostgreSQL Host Configuration Include Path Option (--pg-host-config-include-path)

pgBackRest database host configuration include path.

Set the PostgreSQL host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --pg1-host-config-include-path=/conf/pgbackrest/conf.d

PostgreSQL Host Configuration Path Option (--pg-host-config-path)

pgBackRest database host configuration path.

Set the PostgreSQL host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --pg1-host-config-path=/conf/pgbackrest

PostgreSQL Host Key File Option (--pg-host-key-file)

PostgreSQL host key file.

This key proves that the certificate owner sent the client certificate.

example: --pg1-host-key-file=/path/to/client.key

PostgreSQL Host Port Option (--pg-host-port)

PostgreSQL host port when pg-host is set.

Use this option to specify a non-default port for the PostgreSQL host protocol.

NOTE: When pg-host-type=ssh, pg-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on pg-host-type):
    tls - 8432

allowed: [0, 65535]
example: --pg1-host-port=25

Deprecated Name: db-ssh-port

PostgreSQL Host Protocol Type Option (--pg-host-type)

PostgreSQL host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --pg1-host-type=tls

PostgreSQL Host User Option (--pg-host-user)

PostgreSQL host logon user when pg-host is set.

This user owns the remote pgBackRest process and starts PostgreSQL connections. Use the PostgreSQL cluster owner, usually the default user postgres.

default: postgres
example: --pg1-host-user=db_owner

Deprecated Name: db-user

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: --pg1-path=/data/db

Deprecated Name: db-path

PostgreSQL Port Option (--pg-port)

PostgreSQL port.

Set the PostgreSQL port. Most clusters use the default port, so this setting is usually unnecessary.

default: 5432
allowed: [0, 65535]
example: --pg1-port=6543

Deprecated Name: db-port

PostgreSQL Socket Path Option (--pg-socket-path)

PostgreSQL unix socket path.

Set the Unix socket directory selected at PostgreSQL startup. pgBackRest searches the standard location for your OS automatically. Usually, set this option only if unix_socket_directories in postgresql.conf specifies another directory.

example: --pg1-socket-path=/var/run/postgresql

Deprecated Name: db-socket-path

PostgreSQL Database User Option (--pg-user)

PostgreSQL database user.

Set the database user for PostgreSQL connections. If unset, pgBackRest uses the local OS user or PGUSER.

example: --pg1-user=backupuser

4.16 - Stanza Upgrade Command (stanza-upgrade)

Reference for pgBackRest stanza-upgrade command options and behavior.

Source: pgBackRest Command Docs: stanza-upgrade

Immediately after a PostgreSQL major version upgrade, update pg-path in all pgBackRest configurations to the new database location. Then run stanza-upgrade. It upgrades the stanza in every repository configured on the host. If the database is offline, use --no-online.

Command Options

Online Option (--online)

Update an online cluster.

Specify –no-online to upgrade the stanza without connecting to PostgreSQL.

default: y
example: --no-online

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Database Timeout Option (--db-timeout)

Database query timeout.

Set the database query timeout in seconds. This includes backup start/stop functions, which can each take substantial time. Keep a high timeout unless these functions will return quickly. For example, you have set start-fast=y and know the cluster will generate few WAL segments during the backup.

NOTE: The db-timeout option must be less than the protocol-timeout option.

default: 30m
allowed: [100ms, 7d]
example: --db-timeout=600

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

Stanza Options

PostgreSQL Database Option (--pg-database)

PostgreSQL database.

Set the database name for PostgreSQL connections. The default is usually suitable, but some installations do not have this database.

For compatibility, pgBackRest ignores the PGDATABASE environment variable.

default: postgres
example: --pg1-database=backupdb

PostgreSQL Host Option (--pg-host)

PostgreSQL host for operating remotely.

Use this option when the PostgreSQL host and repository host differ.

example: --pg1-host=db.domain.com

Deprecated Name: db-host

PostgreSQL Host Certificate Authority File Option (--pg-host-ca-file)

PostgreSQL host certificate authority file.

Use a CA file other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

PostgreSQL Host Certificate Authority Path Option (--pg-host-ca-path)

PostgreSQL host certificate authority path.

Use a CA path other than the system default for connecting to the PostgreSQL host.

example: --pg1-host-ca-path=/etc/pki/tls/certs

PostgreSQL Host Certificate File Option (--pg-host-cert-file)

PostgreSQL host certificate file.

pgBackRest sends this certificate to the PostgreSQL host to prove the client identity.

example: --pg1-host-cert-file=/path/to/client.crt

PostgreSQL Host Command Option (--pg-host-cmd)

PostgreSQL host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and PostgreSQL hosts. Otherwise, the PostgreSQL host uses the local command path.

default: [path of executed pgbackrest binary]
example: --pg1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: db-cmd

PostgreSQL Host Configuration Option (--pg-host-config)

pgBackRest database host configuration file.

Set the PostgreSQL host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --pg1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: db-config

PostgreSQL Host Configuration Include Path Option (--pg-host-config-include-path)

pgBackRest database host configuration include path.

Set the PostgreSQL host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --pg1-host-config-include-path=/conf/pgbackrest/conf.d

PostgreSQL Host Configuration Path Option (--pg-host-config-path)

pgBackRest database host configuration path.

Set the PostgreSQL host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --pg1-host-config-path=/conf/pgbackrest

PostgreSQL Host Key File Option (--pg-host-key-file)

PostgreSQL host key file.

This key proves that the certificate owner sent the client certificate.

example: --pg1-host-key-file=/path/to/client.key

PostgreSQL Host Port Option (--pg-host-port)

PostgreSQL host port when pg-host is set.

Use this option to specify a non-default port for the PostgreSQL host protocol.

NOTE: When pg-host-type=ssh, pg-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on pg-host-type):
    tls - 8432

allowed: [0, 65535]
example: --pg1-host-port=25

Deprecated Name: db-ssh-port

PostgreSQL Host Protocol Type Option (--pg-host-type)

PostgreSQL host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --pg1-host-type=tls

PostgreSQL Host User Option (--pg-host-user)

PostgreSQL host logon user when pg-host is set.

This user owns the remote pgBackRest process and starts PostgreSQL connections. Use the PostgreSQL cluster owner, usually the default user postgres.

default: postgres
example: --pg1-host-user=db_owner

Deprecated Name: db-user

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: --pg1-path=/data/db

Deprecated Name: db-path

PostgreSQL Port Option (--pg-port)

PostgreSQL port.

Set the PostgreSQL port. Most clusters use the default port, so this setting is usually unnecessary.

default: 5432
allowed: [0, 65535]
example: --pg1-port=6543

Deprecated Name: db-port

PostgreSQL Socket Path Option (--pg-socket-path)

PostgreSQL unix socket path.

Set the Unix socket directory selected at PostgreSQL startup. pgBackRest searches the standard location for your OS automatically. Usually, set this option only if unix_socket_directories in postgresql.conf specifies another directory.

example: --pg1-socket-path=/var/run/postgresql

Deprecated Name: db-socket-path

PostgreSQL Database User Option (--pg-user)

PostgreSQL database user.

Set the database user for PostgreSQL connections. If unset, pgBackRest uses the local OS user or PGUSER.

example: --pg1-user=backupuser

4.17 - Start Command (start)

Reference for pgBackRest start command options and behavior.

Source: pgBackRest Command Docs: start

After stop prevents pgBackRest processes from running, use start to permit them again. This does not immediately start any processes. See Starting and Stopping for details and examples.

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

4.18 - Stop Command (stop)

Reference for pgBackRest stop command options and behavior.

Source: pgBackRest Command Docs: stop

Prevent new pgBackRest processes from running. By default, existing processes can finish. Use --force to terminate them.

After stop completes, new pgBackRest processes return an error. See Starting and Stopping for details and examples.

Command Options

Force Option (--force)

Force all pgBackRest processes to stop.

Send TERM signals to all running pgBackRest processes for an immediate, graceful shutdown. This also stops processes started elsewhere that have remote processes on this host. For example, stop --force on the database server stops a backup that started on the backup server.

default: n
example: --force

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: --lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

4.19 - Verify Command (verify)

Reference for pgBackRest verify command options and behavior.

Source: pgBackRest Command Docs: verify

Verify checks whether repository backups and archives are valid.

Command Options

Output Option (--output)

Output type.

The following output types are supported:

  • none - No verify output.
  • text - Output verify information to stdout.
default: none
example: --output=text

Set Option (--set)

Backup set to verify.

Verify all database and archive files associated with the specified backup set.

example: --set=20150131-153358F_20150131-153401I

Verbose Option (--verbose)

Verbose output.

The default, false, reports only essential repository error information. Set true for more details about successful verification.

default: n
example: --verbose

General Options

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: --allow-root

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: --buffer-size=2MiB

pgBackRest Command Option (--cmd)

pgBackRest command.

pgBackRest can generate a command string, for example when restore generates the restore_command setting. It uses the command that started the pgBackRest process unless you specify the cmd option.

CAUTION:

Wrapping the pgBackRest command may cause unpredictable behavior and is not recommended.

default: [path of executed pgbackrest binary]
example: --cmd=/var/lib/pgsql/bin/pgbackrest_wrapper.sh

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: --cmd-ssh=/usr/bin/ssh

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: --compress-level-network=1

Config Option (--config)

pgBackRest configuration file.

Use this option to select a configuration file other than the default.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --config=/conf/pgbackrest/pgbackrest.conf

Config Include Path Option (--config-include-path)

Path to additional pgBackRest configuration files.

pgBackRest combines files with the .conf extension in this location with its configuration file. The result is one configuration file.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --config-include-path=/conf/pgbackrest/conf.d

Config Path Option (--config-path)

Base path of pgBackRest configuration files.

Set the default base path for --config and --config-include-path. Explicit command-line values for these options override this setting.

For example, specify only --config-path=/conf/pgbackrest to set the --config default to /conf/pgbackrest/pgbackrest.conf. This also sets the --config-include-path default to /conf/pgbackrest/conf.d.

default: CFGOPTDEF_CONFIG_PATH
example: --config-path=/conf/pgbackrest

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: --io-timeout=120

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: --no-neutral-umask

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: --priority=19

Process Maximum Option (--process-max)

Max processes to use for compress/transfer.

Each process compresses and transfers data to increase command speed. Do not set process-max so high that database performance decreases.

default: 1
allowed: [1, 999]
example: --process-max=4

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE: The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: --protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: --no-sck-keep-alive

Stanza Option (--stanza)

Defines the stanza.

A stanza contains the configuration for a PostgreSQL database cluster. It defines the cluster location, backup method, archive options, and other settings. Most database servers have one PostgreSQL cluster and one stanza. A backup server has a stanza for each cluster that needs a backup.

Choose a stanza name that describes the databases in the cluster. The primary and all replicas use the same stanza name. A functional name, such as app or dw, is preferable to a local cluster name, such as main or prod.

example: --stanza=main

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: --tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: --tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: --tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE: The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: --tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: --log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: --log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: --log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: --log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: --log-subprocess

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: --no-log-timestamp

Maintainer Options

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: --pg-version-force=15

Repository Options

Set Repository Option (--repo)

Set repository.

Set the repository for a command to operate on.

For example, select a repository for a restore instead of letting pgBackRest choose one.

allowed: [1, 256]
example: --repo=1

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: --repo1-azure-container=pg-backup

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: --repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: --repo1-azure-uri-style=path

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: --repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: --repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: --repo1-gcs-endpoint=localhost

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: --repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: --repo1-gcs-user-project=my-project

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: --repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: --repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: --repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: --repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: --repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: --repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: --repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: --repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: --repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE: When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: --repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: --repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: --repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: --repo1-path=/backup/db/backrest

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: --repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: --repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: --repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: --repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: --repo1-s3-process-cmd=/usr/local/bin/get-credentials --repo1-s3-process-cmd=--role --repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: --repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: --no-repo1-s3-requester-pays

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: --repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: --repo1-s3-service=s3-outposts

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: --repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: --repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: --repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: --repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: --repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: --repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: --repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: --repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: --repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: --repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: --repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: --repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: --repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: --repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: --repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: --repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: --no-repo1-storage-verify-tls

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Target Time for Repository Option (--repo-target-time)

Target time for repository.

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

example: --repo-target-time=2024-08-08 12:12:12+00

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: --repo1-type=cifs

4.20 - Version Command (version)

Reference for pgBackRest version command options and behavior.

Source: pgBackRest Command Docs: version

Display the installed pgBackRest version.

Command Options

Output Option (--output)

Output type.

The following output types are supported:

  • text - Display the installed pgBackRest version as text.
  • num - Display the installed pgBackRest version as an integer.
default: text
example: --output=num

5 - Configuration Reference

Complete pgBackRest configuration reference for all settings including archive, backup, repository, and cloud storage options.

Introduction

You can configure pgBackRest entirely with command-line parameters. For complex installations or many options, a configuration file is more practical. Its default location is /etc/pgbackrest/pgbackrest.conf. If that file is absent, pgBackRest checks the old default, /etc/pgbackrest.conf.

The following option types are used:

String: A text string, commonly an identifier, password, etc.

Command line example: --stanza=demo
Configuration file example: repo1-cipher-pass=zWaf6XtpjIVZC5444yXB...

Path: Identify a location in a directory structure. Paths must start with /. They cannot contain double // and should not end with /.

Command line example: --repo1-path=/var/lib/pgbackrest
Configuration file example: repo1-path=/var/lib/pgbackrest

Boolean: Enables or disables the option. Only y/n are valid argument values.

Command line examples: --start-fast, --no-start-fast, --start-fast=y, --start-fast=n
Configuration file examples: start-fast=y, start-fast=n

Integer: Used for ports, retention/retry counts, parallel processes allowed, etc.

Command line example: --compress-level=3
Configuration file example: pg1-port=5432

Size: Specify buffer sizes, disk usage, and similar values. Use bytes (the default), KiB, MiB, GiB, TiB, or PiB. Each unit uses powers of 1024. For example, use 5GiB, 5GB, or 5g instead of 5368709120; values are case-insensitive. Fractional values are not permitted. Use 2560MiB instead of 2.5GiB.

Command line example: --archive-get-queue-max=1GiB
Configuration file example: buffer-size=2MiB

Time: Time in seconds.

Command line example: --io-timeout=90
Configuration file example: db-timeout=600

List: Specify the option multiple times.

Command line example: --db-exclude=db1 --db-exclude=db2 --db-exclude=db5

Configuration file example, each on its own line:

db-exclude=db1
db-exclude=db2
db-exclude=db5

Key/Value: Specify the option multiple times as key=value.

Command line example: --tablespace-map=ts_01=/db/ts_01 --tablespace-map=ts_02=/db/ts_02

Configuration file example, each on its own line:

tablespace-map=ts_01=/db/ts_01
tablespace-map=ts_02=/db/ts_02

Archive Options

The archive section defines options for the archive-push and archive-get commands.

Asynchronous Archiving Option (--archive-async)

Push/get WAL segments asynchronously.

Enables asynchronous operation for the archive-push and archive-get commands.

Asynchronous operation can reuse connections and process work in parallel, which improves efficiency. See spool-path, archive-get-queue-max, and archive-push-queue-max for more information.

default: n
example: archive-async=y

Maximum Archive Get Queue Size Option (--archive-get-queue-max)

Maximum size of the pgBackRest archive-get queue.

When archive-async is enabled, set the maximum archive-get queue size. pgBackRest stores the queue in spool-path to supply WAL to PostgreSQL faster.

default: 128MiB
allowed: [0B, 4PiB]
example: archive-get-queue-max=1GiB

Retry Missing WAL Segment Option (--archive-missing-retry)

Retry missing WAL segment

In asynchronous mode, retry a WAL segment that archive-get previously reported as missing. This prevents reuse of spool-path notifications from an earlier restore. Such notifications could cause recovery to fail before consistency is reached.

Disable this option to help PostgreSQL reliably detect the end of archived WAL and switch to streaming from the primary. With retries enabled, a continuous flow of archived WAL keeps PostgreSQL reading the archive instead of switching to streaming.

Before you disable this option, make sure the stanza spool path is empty. The restore command empties it automatically if the spool path is configured at restore time. Otherwise, empty it yourself.

default: y
example: archive-missing-retry=n

Archive Push Batch Size Option (--archive-push-batch-size)

Maximum amount of WAL to push per asynchronous run.

In asynchronous mode, each archive-push run processes all WAL segments that are ready. It checks archive-push-queue-max only at the start. A large run can let the queue grow far past the limit before the next check.

Set the amount of WAL to process per run. The process then exits, and the next archive-push starts it again and checks the queue. Lower values check the queue more often but start the asynchronous process more frequently. pgBackRest rounds the value down to a whole number of WAL segments. It always processes at least one segment.

default: 16GiB
allowed: [1MiB, 4PiB]
example: archive-push-batch-size=1GiB

Maximum Archive Push Queue Size Option (--archive-push-queue-max)

Maximum size of the PostgreSQL archive queue.

When the queue reaches the limit:

  • pgBackRest tells PostgreSQL that it archived the WAL successfully, then DROPS IT.
  • PostgreSQL logs a warning.

This interrupts the archive log stream. PITR cannot continue past this point. Take a new backup to restore full recovery capability.

In asynchronous mode, pgBackRest drops the entire queue. This prevents brief WAL transfers before the queue exceeds the limit again.

In asynchronous mode, each archive-push run checks this limit only at the start. The queue can exceed it during the run. Reduce archive-push-batch-size to check more often.

This feature prevents WAL from filling the log volume, which would stop PostgreSQL completely. It sacrifices backup continuity to keep PostgreSQL running.

allowed: [0B, 4PiB]
example: archive-push-queue-max=1TiB

Deprecated Name: archive-queue-max

Archive Timeout Option (--archive-timeout)

Archive timeout.

Set the maximum wait, in seconds, for each WAL segment to reach the pgBackRest archive repository. The check and backup commands use this timeout while waiting for WAL segments necessary for backup consistency.

default: 1m
allowed: [100ms, 1d]
example: archive-timeout=30

Backup Options

The backup section defines settings related to backup.

Backup Annotation Option (--annotation)

Annotate backup with user-defined key/value pairs.

Attach informative key/value pairs to the backup. Repeat this option to attach multiple annotations.

When --set specifies a backup, the info command includes its annotations in text output. JSON output always includes annotations.

example: annotation=source="Sunday backup for website database"

Check Archive Option (--archive-check)

Check that WAL segments are in the archive before backup completes.

Check that the WAL archive contains all segments necessary for backup consistency. Keep the default unless you use another archive method.

This option must be enabled if archive-copy is enabled.

default: y
example: archive-check=n

Copy Archive Option (--archive-copy)

Copy WAL segments needed for consistency to the backup.

Store WAL segments necessary for consistency directly in the backup. This protects against corruption in the WAL archive. The archive still stores these segments, so this option uses additional space.

When you use this option, give archive-push and backup the same compress-type, such as lz4. Otherwise, pgBackRest must recompress WAL segments with the backup compression type. This can require substantial processing when the backup generates a large amount of WAL.

After a restore, these WAL segments are in pg_xlog/pg_wal. PostgreSQL uses them before it calls restore_command.

The archive-check option must be enabled if archive-copy is enabled.

default: n
example: archive-copy=y

Check Archive Mode Option (--archive-mode-check)

Check the PostgreSQL archive_mode setting.

Enabled by default, this option disallows PostgreSQL archive_mode=always.

A standby can push WAL segments with the same logical contents as primary segments but different checksums. Disable archiving from multiple sources to avoid these conflicts.

CAUTION:

If you disable this option, make sure that only one archiver writes to the repository through archive-push.

default: y
example: archive-mode-check=n

Backup from Standby Option (--backup-standby)

Backup from the standby cluster.

Enable backups from the standby to reduce primary cluster load. Configure both the primary and standby hosts to use this option.

The following modes are supported:

  • y - Standby is required for backup.
  • prefer - Backup from standby if available otherwise backup from primary.
  • n - Backup from primary only.
default: n
example: backup-standby=y

Page Checksums Option (--checksum-page)

Validate data page checksums.

Validate all data page checksums during a cluster backup. pgBackRest enables this option automatically when the cluster has data page checksums enabled.

Checksum validation failures do not stop a backup. pgBackRest writes warnings to the log and, with default settings, the console. It stores the invalid page list in the backup manifest.

example: checksum-page=n

Path/File Exclusions Option (--exclude)

Exclude paths/files from the backup.

All exclusions are relative to $PGDATA. An exclusion ending in / excludes files in the directory but keeps the directory itself. For example, --exclude=junk/ excludes files in $PGDATA/junk. Without a final /, an exclusion matches either the exact file name or the name followed by /. For example, --exclude=junk excludes the $PGDATA/junk directory and all its files.

Use this feature with care. An excluded critical file can make the backup inconsistent. Test your restores.

pgBackRest logs each excluded file and its exclusion rule at info level. Review the list to make sure all exclusions are intended.

NOTE:

Delta restores do not preserve exclusions. They remove files and directories that the backup excluded.

Do not use this option to exclude PostgreSQL logs. Use PostgreSQL log_directory to move logs outside PGDATA. This also preserves logs after a restore.

Specify multiple exclusions on the command line or in a configuration file.

example: exclude=junk/

Expire Auto Option (--expire-auto)

Automatically run the expire command after a successful backup.

This setting is enabled by default. Disable it with care: pgBackRest then keeps all backups and archives indefinitely, which can fill the repository. Run expire regularly to prevent this.

Automatic expiration after a successful backup uses the backup command configuration. Options set only in an expire command section, such as [global:expire], do not apply. To use those options, disable automatic expiration and run expire separately.

default: y
example: expire-auto=y

Manifest Save Threshold Option (--manifest-save-threshold)

Manifest save threshold during backup.

Set how often pgBackRest saves the manifest during a backup. The manifest stores checksums so that backup resume can work efficiently. The actual threshold is 1% of backup size or manifest-save-threshold, whichever is greater.

default: 1GiB
allowed: [1B, 1TiB]
example: manifest-save-threshold=8GiB

Resume Option (--resume)

Allow resume of failed backup.

Enable or disable backup resume. After a backup fails, resume can substantially reduce the time for another backup of the same type. This feature adds complexity. You can disable it in environments that do not need it.

default: y
example: resume=n

Start Fast Option (--start-fast)

Force a checkpoint to start backup quickly.

Pass y to the backup start function fast parameter to force a checkpoint and start the backup immediately. Otherwise, the backup waits for the next regular checkpoint.

default: n
example: start-fast=y

General Options

The general section defines options that are common for many commands.

Allow Run as Root Option (--allow-root)

Allow the command to run as the root user.

By default, only restore can run as root because it manages file ownership. Other commands can create root-owned files, for example in the repository. The PostgreSQL user cannot access these files, which causes later commands to fail.

Enable this option to run another command as root. Preferably, run pgBackRest as the user that owns the repository and PostgreSQL cluster.

default: n
example: allow-root=y

Buffer Size Option (--buffer-size)

Buffer size for I/O operations.

Set the buffer size for copy, compression, encryption, and other operations. Options determine the number of buffers. Each operation can also use more memory. For example, gz compression can use an additional 256KiB.

Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB, and 16MiB.

default: 1MiB
example: buffer-size=2MiB

pgBackRest Command Option (--cmd)

pgBackRest command.

pgBackRest can generate a command string, for example when restore generates the restore_command setting. It uses the command that started the pgBackRest process unless you specify the cmd option.

CAUTION:

Wrapping the pgBackRest command may cause unpredictable behavior and is not recommended.

default: [path of executed pgbackrest binary]
example: cmd=/var/lib/pgsql/bin/pgbackrest_wrapper.sh

SSH Client Command Option (--cmd-ssh)

SSH client command.

Use this option to select a different SSH client or when the ssh command is not in $PATH.

default: ssh
example: cmd-ssh=/usr/bin/ssh

Compress Option (--compress)

Use file compression.

Backup files are compatible with command-line compression tools.

This option is deprecated. Use compress-type instead.

default: y
example: compress=n

Compress Level Option (--compress-level)

File compression level.

Set the file compression level when compress-type is not none or when compress=y (deprecated).

default (depending on compress-type):
    bz2 - 9
    gz - 6
    lz4 - 1
    zst - 3

allow range (depending on compress-type):
    bz2 - [1, 9]
    gz - [-1, 9]
    lz4 - [-5, 12]
    zst - [-7, 22]

example: compress-level=9

Network Compress Level Option (--compress-level-network)

Network compression level.

Set the network compression level when compress-type=none and the command runs on a host other than the repository host. Compression reduces network traffic. When compress-type is not none, pgBackRest ignores compress-level-network and uses compress-level. This prevents compression of the same file twice.

default: 1
allowed: [-5, 12]
example: compress-level-network=1

Compress Type Option (--compress-type)

File compression type.

The following compression types are supported:

  • none - no compression
  • bz2 - bzip2 compression format
  • gz - gzip compression format
  • lz4 - lz4 compression format (not available on all platforms)
  • zst - Zstandard compression format (not available on all platforms)
default: gz
example: compress-type=none

Database Timeout Option (--db-timeout)

Database query timeout.

Set the database query timeout in seconds. This includes backup start/stop functions, which can each take substantial time. Keep a high timeout unless these functions will return quickly. For example, you have set start-fast=y and know the cluster will generate few WAL segments during the backup.

NOTE:

The db-timeout option must be less than the protocol-timeout option.

default: 30m
allowed: [100ms, 7d]
example: db-timeout=600

Delta Option (--delta)

Restore or backup using checksums.

By default, a restore expects existing but empty PostgreSQL data and tablespace directories. Enable this option for a delta restore that uses checksums.

During a backup, use checksums instead of timestamps to determine which files to copy.

default: n
example: delta=y

I/O Timeout Option (--io-timeout)

I/O timeout.

Set the connection and read/write timeout in seconds.

The complete read/write operation can take longer than this timeout. However, it must make some progress before the timeout, even if only one byte.

default: 1m
allowed: [100ms, 1h]
example: io-timeout=120

Lock Path Option (--lock-path)

Path where lock files are stored.

pgBackRest creates lock files in this path to prevent conflicting operations from running at the same time.

default: /tmp/pgbackrest
example: lock-path=/backup/db/lock

Neutral Umask Option (--neutral-umask)

Use a neutral umask.

Set the umask to 0000 to control repository permissions. The default directory mode is 0750. The default file mode is 0640.

To use the executing user’s umask, set neutral-umask=n in the configuration file or --no-neutral-umask on the command line.

default: y
example: neutral-umask=n

Set Process Priority Option (--priority)

Set process priority.

Set the process priority, or niceness, used by the kernel scheduler. Positive values decrease priority. Negative values increase priority. Processes usually lack permission to increase their priority.

allowed: [-20, 19]
example: priority=19

Process Maximum Option (--process-max)

Max processes to use for compress/transfer.

Each process compresses and transfers data to increase command speed. Do not set process-max so high that database performance decreases.

default: 1
allowed: [1, 999]
example: process-max=4

Protocol Timeout Option (--protocol-timeout)

Protocol timeout.

Set how many seconds a local or remote process waits for a new protocol message. This prevents an indefinite wait.

NOTE:

The protocol-timeout option must be greater than the db-timeout option.

default: 31m
allowed: [100ms, 7d]
example: protocol-timeout=630

Keep Alive Option (--sck-keep-alive)

Keep-alive enable.

Enables keep-alive messages on socket connections.

default: y
example: sck-keep-alive=n

Spool Path Option (--spool-path)

Path where transient data is stored.

This path stores data for asynchronous archive-push and archive-get commands.

After it stores WAL in the archive, asynchronous archive-push writes an acknowledgement in the spool path. On failure, it writes an error. The foreground process can then notify PostgreSQL quickly. Acknowledgement files contain zero bytes on success and a few hundred bytes on error.

Asynchronous archive-get queues WAL in the spool path to supply it quickly when PostgreSQL requests it. Transfers are most efficient when the spool path uses the same filesystem as pg_xlog/pg_wal. However, do not put the spool path inside pg_xlog/pg_wal. This can cause problems for PostgreSQL utilities, such as pg_rewind.

Spool-path data can and should survive a reboot. However, loss of this data does not cause a problem. For archive-push, pgBackRest checks again that each WAL segment is safely archived. For archive-get, it rebuilds the queue.

Use a local Posix-compatible filesystem for the spool path. It is not intended for remote filesystems, such as NFS or CIFS.

default: /var/spool/pgbackrest
example: spool-path=/backup/db/spool

Keep Alive Count Option (--tcp-keep-alive-count)

Keep-alive count.

Set how many TCP keep-alive messages can be lost before the connection is considered dead.

This option is available on systems that support the TCP_KEEPCNT socket option.

allowed: [1, 32]
example: tcp-keep-alive-count=3

Keep Alive Idle Option (--tcp-keep-alive-idle)

Keep-alive idle time.

Set how many seconds of network inactivity must pass before the operating system sends a TCP keep-alive message.

This option is available on systems that support the TCP_KEEPIDLE socket option.

allowed: [1, 3600]
example: tcp-keep-alive-idle=60

Keep Alive Interval Option (--tcp-keep-alive-interval)

Keep-alive interval time.

Set how many seconds to wait before retransmitting a TCP keep-alive message that has no acknowledgement.

This option is available on systems that support the TCP_KEEPINTVL socket option.

allowed: [1, 900]
example: tcp-keep-alive-interval=30

TLSv1.2 cipher suites Option (--tls-cipher-12)

Allowed TLSv1.2 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE:

The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. The example is suitable unless you have specific security requirements. By default, this option is unset and the underlying OpenSSL library default applies.

example: tls-cipher-12=HIGH:MEDIUM:+3DES:!aNULL

TLSv1.3 cipher suites Option (--tls-cipher-13)

Allowed TLSv1.3 cipher suites.

All TLS connections between the pgBackRest client and server use encryption. Connections to object stores, such as S3, also use encryption by default.

NOTE:

The absolute minimum security level for any transport connection is TLSv1.2.

Change the accepted cipher suites if necessary. By default, this option is unset and the underlying OpenSSL library default applies.

example: tls-cipher-13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Log Options

The log section defines logging-related settings.

CAUTION:

Trace-level logs can expose secrets, including keys and passwords. Use them with care.

Console Log Level Option (--log-level-console)

Level for console logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: warn
example: log-level-console=error

File Log Level Option (--log-level-file)

Level for file logging.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: info
example: log-level-file=debug

Std Error Log Level Option (--log-level-stderr)

Level for stderr logging.

Select the log levels that write to stderr instead of stdout, which log-level-console controls. Output to stderr excludes the timestamp and process.

The following log levels are supported:

  • off - No logging at all (not recommended)
  • error - Log only errors
  • warn - Log warnings and errors
  • info - Log info, warnings, and errors
  • detail - Log detail, info, warnings, and errors
  • debug - Log debug, detail, info, warnings, and errors
  • trace - Log trace (very verbose debugging), debug, info, warnings, and errors
default: off
example: log-level-stderr=error

Log Path Option (--log-path)

Path where log files are stored.

pgBackRest stores log files in this path. If log-level-file=off, no log path is necessary.

default: /var/log/pgbackrest
example: log-path=/backup/db/log

Log Subprocesses Option (--log-subprocess)

Enable logging in subprocesses.

Enable file logging for subprocesses created by this process. Use the level specified by log-level-file.

default: n
example: log-subprocess=y

Log Timestamp Option (--log-timestamp)

Enable timestamp in logging.

Include timestamps in console and file logs. Disable this option for special uses, such as documentation generation.

default: y
example: log-timestamp=n

Maintainer Options

Maintainer options support PostgreSQL forks. The fork maintainer should determine the correct settings and give them to users.

WARNING:

Improper use of these options may lead to unexpected behavior or data corruption.

The fork maintainer must test pgBackRest with the required options. pgBackRest does not guarantee compatibility with any fork.

Check WAL Headers Option (--archive-header-check)

Check PostgreSQL version/id in WAL headers.

This option is enabled by default. It compares WAL headers with the PostgreSQL version and system identifier to check that WAL goes to the correct stanza. pgBackRest also checks pg_control against the stanza. It verifies that WAL comes from the PostgreSQL data directory that contains pg_control.

Thus, disabling this check is relatively safe. Disable it only when necessary, for example for encrypted WAL.

default: y
example: archive-header-check=n

Page Header Check Option (--page-header-check)

Check PostgreSQL page headers.

Enabled by default, this option adds page header checks.

Disable this option only when necessary, for example for encrypted pages.

default: y
example: page-header-check=n

Force PostgreSQL Version Option (--pg-version-force)

Force PostgreSQL version.

Use the specified PostgreSQL version instead of the version detected from pg_control or WAL headers. This is mainly useful for PostgreSQL forks or development versions whose values differ from the release version. The version that PostgreSQL reports through server_version_num must match the forced version.

WARNING:

Use this option with care. pgBackRest still reads pg_control and WAL headers in the official open-source PostgreSQL format for the specified version. Changes to fields that pgBackRest uses can cause unexpected behavior. Generally, the fork must add all custom struct members after the standard PostgreSQL members for this option to work correctly.

example: pg-version-force=15

Repository Options

The repository section defines options used to configure the repository.

Indexing: Every repo- option has an index to support multiple repositories. For one repository, use options such as repo1-path and repo1-host. With multiple repositories and no --repo command option, operations follow priority order: repo1, then repo2, and so on.

The repo-retention-* options control backup retention. With count-based retention, expiration starts only when completed backups exceed the allowed count. For example, set repo1-retention-full-type to count (the default) and repo1-retention-full to 2. The oldest backup expires after 3 complete backups. With repo1-retention-full-type set to time, repo1-retention-full specifies days. Expiration requires at least that many days of full backups. Always reserve space for retention + 1 backups.

Azure Repository Account Option (--repo-azure-account)

Azure repository account.

Azure account used to store the repository.

example: repo1-azure-account=pg-backup

Azure Repository Container Option (--repo-azure-container)

Azure repository container.

Azure container used to store the repository.

Set repo-path=/ to store the repository in the container root. Usually, specify a prefix such as /repo. The container can then also store logs and other Azure-generated content.

example: repo1-azure-container=pg-backup

Azure Repository Endpoint Option (--repo-azure-endpoint)

Azure repository endpoint.

Set the blob service endpoint. The default is usually correct unless you use Azure Government.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

default: blob.core.windows.net
example: repo1-azure-endpoint=blob.core.usgovcloudapi.net

Azure Repository Key Option (--repo-azure-key)

Azure repository key.

A shared key or shared access signature depending on the repo-azure-key-type option.

example: repo1-azure-key=T+9+aov82qNhrcXSNGZCzm9mjd4d75/oxxOr6r1JVpgTLA==

Azure Repository Key Type Option (--repo-azure-key-type)

Azure repository key type.

The following types are supported for authorization:

  • shared - Shared key
  • sas - Shared access signature
  • auto - Automatically authorize using Azure managed identities
default: shared
example: repo1-azure-key-type=sas

Azure Repository URI Style Option (--repo-azure-uri-style)

Azure URI Style.

The following URI styles are supported:

  • host - Connect to account.endpoint host.
  • path - Connect to endpoint host and prepend account to URIs.
default: host
example: repo1-azure-uri-style=path

Block Incremental Backup Option (--repo-block)

Enable block incremental backup.

Block incremental backup divides files into blocks that can be backed up independently. This saves repository space. It can also improve delta restore performance because pgBackRest can fetch individual blocks without reading the entire repository file.

NOTE:

The repo-bundle option must be enabled before repo-block can be enabled.

File size and age determine block size. Older or larger files generally use larger blocks. Files above the age threshold do not use block incremental backup.

For maximum efficiency, enable block incremental for all backup types, including full backups. Full backups become slightly larger. Later differential and incremental backups use their block maps to save space.

default: n
example: repo1-block=y

Repository Bundles Option (--repo-bundle)

Bundle files in repository.

Combine smaller files into bundles to reduce the number of repository files. Fewer file writes usually improve efficiency, especially with object stores such as S3. Zero-length files have only manifest entries and no stored file contents. This saves time and space.

default: n
example: repo1-bundle=y

Repository Bundle Limit Option (--repo-bundle-limit)

Limit for file bundles.

Set the maximum file size for inclusion in bundles. Larger files are stored separately.

A resumed backup cannot reuse bundled files. Higher limits put more files in bundles and leave fewer files available for resume.

default: 2MiB
allowed: [8KiB, 1PiB]
example: repo1-bundle-limit=10MiB

Repository Bundle Size Option (--repo-bundle-size)

Target size for file bundles.

Set the target size of one file bundle. The uncompressed bundle can be as large as repo-bundle-size + repo-bundle-limit. Do not set this option to the maximum file size your filesystem permits.

Avoid very large bundles. A retry must repeat the entire bundle.

default: 20MiB
allowed: [1MiB, 1PiB]
example: repo1-bundle-size=10MiB

Repository Cipher Passphrase Option (--repo-cipher-pass)

Repository cipher passphrase.

Passphrase used to encrypt/decrypt files of the repository.

NOTE:

Without stanza, info reads encryption settings only from global. For stanza-specific encryption settings, run info with stanza to read the encrypted stanza.

example: repo1-cipher-pass=zWaf6XtpjIVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO

Repository Cipher Type Option (--repo-cipher-type)

Cipher used to encrypt the repository.

The following cipher types are supported:

  • none - The repository is not encrypted
  • aes-256-cbc - Advanced Encryption Standard with 256 bit key length

pgBackRest always encrypts data on the client, even when the repository type, such as S3, supports encryption.

default: none
example: repo1-cipher-type=aes-256-cbc

GCS Repository Bucket Option (--repo-gcs-bucket)

GCS repository bucket.

GCS bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other GCS-generated content.

example: repo1-gcs-bucket=/pg-backup

GCS Repository Endpoint Option (--repo-gcs-endpoint)

GCS repository endpoint.

Set the endpoint for the storage service connection. You can select a local GCS server or another endpoint.

default: storage.googleapis.com
example: repo1-gcs-endpoint=localhost

GCS Repository Key Option (--repo-gcs-key)

GCS repository key.

A token or service key file depending on the repo-gcs-key-type option.

example: repo1-gcs-key=/etc/pgbackrest/gcs-key.json

GCS Repository Key Type Option (--repo-gcs-key-type)

GCS repository key type.

The following types are supported for authorization:

  • auto - Authorize using the instance service account.
  • service - Service account from locally stored key.
  • token - For local testing, e.g. fakegcs.

When repo-gcs-key-type=service, pgBackRest reloads credentials when it renews the authentication token.

default: service
example: repo1-gcs-key-type=auto

GCS Repository Project ID Option (--repo-gcs-user-project)

GCS project ID.

GCS project ID used to determine request billing.

example: repo1-gcs-user-project=my-project

Hardlink files between backups in the repository.

Hard-link differential and incremental backup files to their full backups. Each backup then appears to be a full backup at the filesystem level. Use care: changes to hard-linked files can affect every backup in the set.

default: n
example: repo1-hardlink=y

Deprecated Name: hardlink

Repository Host Option (--repo-host)

Repository host when operating remotely.

This setting is not necessary for backups and archives on a locally mounted filesystem.

example: repo1-host=repo1.domain.com

Deprecated Name: backup-host

Repository Host Certificate Authority File Option (--repo-host-ca-file)

Repository host certificate authority file.

Use a CA file other than the system default for connecting to the repository host.

example: repo1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Repository Host Certificate Authority Path Option (--repo-host-ca-path)

Repository host certificate authority path.

Use a CA path other than the system default for connecting to the repository host.

example: repo1-host-ca-path=/etc/pki/tls/certs

Repository Host Certificate File Option (--repo-host-cert-file)

Repository host certificate file.

pgBackRest sends this certificate to the repository host to prove the client identity.

example: repo1-host-cert-file=/path/to/client.crt

Repository Host Command Option (--repo-host-cmd)

Repository host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and repository hosts. Otherwise, the repository host uses the local command path.

default: [path of executed pgbackrest binary]
example: repo1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: backup-cmd

Repository Host Configuration Option (--repo-host-config)

pgBackRest repository host configuration file.

Set the repository host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: repo1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: backup-config

Repository Host Configuration Include Path Option (--repo-host-config-include-path)

pgBackRest repository host configuration include path.

Set the repository host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: repo1-host-config-include-path=/conf/pgbackrest/conf.d

Repository Host Configuration Path Option (--repo-host-config-path)

pgBackRest repository host configuration path.

Set the repository host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: repo1-host-config-path=/conf/pgbackrest

Repository Host Key File Option (--repo-host-key-file)

Repository host key file.

This key proves that the certificate owner sent the client certificate.

example: repo1-host-key-file=/path/to/client.key

Repository Host Port Option (--repo-host-port)

Repository host port when repo-host is set.

Use this option to specify a non-default port for the repository host protocol.

NOTE:

When repo-host-type=ssh, repo-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on repo-host-type):
    tls - 8432

allowed: [0, 65535]
example: repo1-host-port=25

Deprecated Name: backup-ssh-port

Repository Host Protocol Type Option (--repo-host-type)

Repository host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: repo1-host-type=tls

Repository Host User Option (--repo-host-user)

Repository host user when repo-host is set.

Set the user for repository host operations. Prefer a separate user, such as pgbackrest, to the postgres user. If PostgreSQL runs on the repository host, you can add postgres to the pgbackrest group. This gives it read access to the repository without permission to damage its contents accidentally.

default: pgbackrest
example: repo1-host-user=repo-user

Deprecated Name: backup-user

Repository Path Option (--repo-path)

Path where backups and archive are stored.

The repository is where pgBackRest stores backups and archives WAL segments.

To estimate repository space, take some backups. Record the sizes of full, incremental, and differential backups (full/incr/diff). Measure how much WAL the database generates each day. These measurements give an approximate space requirement. Requirements will probably change as the database changes.

default: /var/lib/pgbackrest
example: repo1-path=/backup/db/backrest

Archive Retention Option (--repo-retention-archive)

Number of backups worth of continuous WAL to retain.

NOTE:

WAL segments necessary for backup consistency remain until the backup expires, regardless of this option.

If this value is unset and repo-retention-full-type is count (the default), archive retention follows backup retention. When repo-retention-archive-type is full, it uses repo-retention-full. When the archive type is diff, it uses repo-retention-diff. Thus, WAL expires only for backups that have already expired. If repo-retention-full-type is time, the default removes archives older than the oldest full backup retained to satisfy repo-retention-full.

Set this option when repo-retention-archive-type is incr. With limited disk space, use it with repo-retention-archive-type to expire WAL segments more aggressively. However, backups with expired WAL cannot support PITR. This is not recommended.

allowed: [1, 9999999]
example: repo1-retention-archive=2

Deprecated Name: retention-archive

Archive Retention Type Option (--repo-retention-archive-type)

Backup type for WAL retention.

When set to full, retain archive logs for the number of full backups specified by repo-retention-archive. When set to diff, count both full and differential backups. Thus, if the latest backup is full, it counts as a differential for repo-retention. When set to incr, count full, differential, and incremental backups. Prefer the default, which expires WAL only when full backups expire.

default: full
example: repo1-retention-archive-type=diff

Deprecated Name: retention-archive-type

Differential Retention Option (--repo-retention-diff)

Number of differential backups to retain.

When a differential backup expires, its dependent incremental backups also expire. If this option is unset, differential backups remain until their parent full backups expire.

The differential backup count includes full backups. In most cases, this slightly reduces the number of differential backups retained.

allowed: [1, 9999999]
example: repo1-retention-diff=3

Deprecated Name: retention-diff

Full Retention Option (--repo-retention-full)

Full backup retention count/time.

When a full backup expires, its dependent differential and incremental backups also expire. If this option is unset, pgBackRest reports a warning. For indefinite retention, use the maximum value.

allowed: [1, 9999999]
example: repo1-retention-full=2

Deprecated Name: retention-full

Full Retention Type Option (--repo-retention-full-type)

Retention type for full backups.

Select whether repo-retention-full specifies a number of days or a count of full backups to keep.

With time, pgBackRest removes full backups older than repo-retention-full only if another retained backup is at least that old. For example, set repo-retention-full to 30 days with two full backups aged 25 and 35 days. Neither expires. Removing the 35-day backup would leave only the 25-day backup, which cannot satisfy the 30-day policy. Archived WAL older than the oldest remaining full backup expires automatically unless you explicitly set repo-retention-archive-type and repo-retention-archive.

With count, pgBackRest expires full backups that exceed repo-retention-full. For example, with repo-retention-full set to 4, completion of a fifth full backup expires the oldest, leaving 4.

Only successfully completed backups count toward retention. For example, set repo-retention-full-type to count and repo-retention-full to 2. The oldest full backup expires only after 3 full backups complete.

default: count
example: repo1-retention-full-type=time

Backup History Retention Option (--repo-retention-history)

Days of backup history manifests to retain.

When a backup completes, pgBackRest copies its manifest to backup.history. By default, these files never expire. They support analysis, such as measurements of backup and WAL growth over time.

Set repo-retention-history to the number of days of backup history manifests to retain. History always includes unexpired backups. Set repo-retention-history=0 to keep history only for unexpired backups.

When a full backup history manifest expires, its dependent differential and incremental backup history manifests also expire.

allowed: [0, 9999999]
example: repo1-retention-history=365

S3 Repository Bucket Option (--repo-s3-bucket)

S3 repository bucket.

S3 bucket used to store the repository.

Set repo-path=/ to store the repository in the bucket root. Usually, specify a prefix such as /repo. The bucket can then also store logs and other AWS-generated content.

example: repo1-s3-bucket=pg-backup

S3 Repository Endpoint Option (--repo-s3-endpoint)

S3 repository endpoint.

The AWS endpoint should be valid for the selected region.

For custom/test configurations the repo-storage-ca-file, repo-storage-ca-path, repo-storage-host, repo-storage-port, and repo-storage-verify-tls options may be useful.

example: repo1-s3-endpoint=s3.amazonaws.com

S3 Repository Access Key Option (--repo-s3-key)

S3 repository access key.

AWS key used to access this bucket.

example: repo1-s3-key=AKIAIOSFODNN7EXAMPLE

S3 Repository Secret Access Key Option (--repo-s3-key-secret)

S3 repository secret access key.

AWS secret key used to access this bucket.

example: repo1-s3-key-secret=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

S3 Repository Key Type Option (--repo-s3-key-type)

S3 repository key type.

The following types are supported:

  • shared - Shared keys
  • auto - Automatically retrieve temporary credentials
  • web-id - Automatically retrieve web identity credentials
  • pod-id - Automatically retrieve EKS pod identity credentials
  • process - Retrieve credentials by executing a process
default: shared
example: repo1-s3-key-type=auto

S3 Repository KMS Key ID Option (--repo-s3-kms-key-id)

S3 repository KMS key.

Enables S3 server-side encryption using the specified AWS key management service key.

example: repo1-s3-kms-key-id=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Authentication Process Command Option (--repo-s3-process-cmd)

S3 authentication process command.

Set the command and optional arguments that retrieve temporary S3 credentials. The first list entry is the command. The remaining entries are its parameters.

The process must output JSON with AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields. pgBackRest refreshes credentials automatically before they expire. See Process Credential Provider for the format.

example: repo1-s3-process-cmd=/usr/local/bin/get-credentials
example: repo1-s3-process-cmd=--role
example: repo1-s3-process-cmd=my-role

S3 Repository Region Option (--repo-s3-region)

S3 repository region.

The AWS region where the bucket was created.

example: repo1-s3-region=us-east-1

S3 Repository Requestor Pays Option (--repo-s3-requester-pays)

S3 repository requester pays.

Enables S3 requester pays.

default: n
example: repo1-s3-requester-pays=n

S3 Repository Role Option (--repo-s3-role)

S3 repository role.

When repo-s3-key-type=auto, set the AWS role name used to retrieve temporary credentials. Use the name, not the full ARN.

example: repo1-s3-role=authrole

S3 Repository Service Option (--repo-s3-service)

S3 signing service.

Set the signing service for SigV4 authentication. The default is s3 for standard S3 endpoints. For an S3 Outposts endpoint, use s3-outposts.

default: s3
example: repo1-s3-service=s3-outposts

S3 Repository SSE Customer Key Option (--repo-s3-sse-customer-key)

S3 repository SSE customer key.

Enables S3 server-side encryption using the specified customer key.

example: repo1-s3-sse-customer-key=bceb4f13-6939-4be3-910d-df54dee817b7

S3 Repository STS Endpoint Option (--repo-s3-sts-host)

S3 repository STS endpoint.

When repo-s3-key-type=web-id, this endpoint retrieves temporary credentials. To use regional STS, select a regional endpoint, such as sts.us-east-1.amazonaws.com. Regional STS might be necessary for GovCloud or China regions, or to reduce latency.

default: sts.amazonaws.com
example: repo1-s3-sts-host=sts.us-east-1.amazonaws.com

S3 Repository Security Token Option (--repo-s3-token)

S3 repository security token.

AWS security token used with temporary credentials.

example: repo1-s3-token=AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22 ...

S3 Repository URI Style Option (--repo-s3-uri-style)

S3 URI Style.

The following URI styles are supported:

  • host - Connect to bucket.endpoint host.
  • path - Connect to endpoint host and prepend bucket to URIs.
default: host
example: repo1-s3-uri-style=path

SFTP Repository Host Option (--repo-sftp-host)

SFTP repository host.

The SFTP host containing the repository.

example: repo1-sftp-host=sftprepo.domain

SFTP Repository Host Fingerprint Option (--repo-sftp-host-fingerprint)

SFTP repository host fingerprint.

Generate the SFTP host fingerprint with the hash type specified by repo-sftp-host-key-hash-type. Use awk '{print $2}' ssh_host_xxx_key.pub | base64 -d | (md5sum or sha1sum) -b. SSH host keys are usually in /etc/ssh.

example: repo1-sftp-host-fingerprint=f84e172dfead7aeeeae6c1fdfb5aa8cf

SFTP Host Key Check Type Option (--repo-sftp-host-key-check-type)

SFTP host key check type.

The following SFTP host key check types are supported:

  • strict - pgBackRest never adds host keys to ~/.ssh/known_hosts automatically. It refuses connections when a host key changes or is absent from the known hosts files. Add each new host manually.
  • accept-new - pgBackRest automatically adds new host keys to the user’s known hosts file. It refuses connections when a host key changes.
  • fingerprint - pgBackRest compares the host key with the repo-sftp-host-fingerprint value.
  • none - pgBackRest does not check host keys.
default: strict
example: repo1-sftp-host-key-check-type=accept-new

SFTP Repository Host Key Hash Type Option (--repo-sftp-host-key-hash-type)

SFTP repository host key hash type.

Set the hash type used to calculate the remote host key digest at SSH startup. Newer libssh2 versions support sha256 as well as md5 and sha1.

example: repo1-sftp-host-key-hash-type=sha256

SFTP Repository Host Port Option (--repo-sftp-host-port)

SFTP repository host port.

SFTP repository host port.

default: 22
allowed: [1, 65535]
example: repo1-sftp-host-port=22

SFTP Repository Host User Option (--repo-sftp-host-user)

SFTP repository host user.

User on the host used to store the repository.

example: repo1-sftp-host-user=pg-backup

SFTP Known Hosts File Option (--repo-sftp-known-host)

SFTP known hosts file.

Set a known hosts file to check during SFTP authentication. By default, pgBackRest searches ~/.ssh/known_hosts, ~/.ssh/known_hosts2, /etc/ssh/ssh_known_hosts, and /etc/ssh/ssh_known_hosts2. If you configure file paths, it searches those files. Use absolute paths or paths that start with a tilde. Repeat repo-sftp-known-host to specify multiple files. To check known hosts files, do not set repo-sftp-host-fingerprint.

See also the repo-sftp-host-check-type option.

example: repo1-sftp-known-host=/home/postgres/.ssh/known_hosts

SFTP Repository Private Key File Option (--repo-sftp-private-key-file)

SFTP private key file.

SFTP private key file used for authentication.

example: repo1-sftp-private-key-file=~/.ssh/id_ed25519

SFTP Repository Private Key Passphrase Option (--repo-sftp-private-key-passphrase)

SFTP private key passphrase.

Set the passphrase for the private key. A passphrase is optional when you create an SSH public/private key pair.

example: repo1-sftp-private-key-passphrase=BeSureToGenerateAndUseASecurePassphrase

SFTP Repository Public Key File Option (--repo-sftp-public-key-file)

SFTP public key file.

Set the SFTP public key file for authentication. This file is optional for builds that use OpenSSL. Other builds require it.

example: repo1-sftp-public-key-file=~/.ssh/id_ed25519.pub

Repository Storage CA File Option (--repo-storage-ca-file)

Repository storage CA file.

Use a CA file other than the system default for storage (e.g. S3, Azure) certificates.

example: repo1-storage-ca-file=/etc/pki/tls/certs/ca-bundle.crt

Deprecated Names: repo-azure-ca-file, repo-s3-ca-file

Repository Storage TLS CA Path Option (--repo-storage-ca-path)

Repository storage CA path.

Use a CA path other than the system default for storage (e.g. S3, Azure) certificates.

example: repo1-storage-ca-path=/etc/pki/tls/certs

Deprecated Names: repo-azure-ca-path, repo-s3-ca-path

Repository Storage Host Option (--repo-storage-host)

Repository storage host.

Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is typically used for testing.

example: repo1-storage-host=127.0.0.1

Deprecated Names: repo-azure-host, repo-s3-host

Repository Storage Port Option (--repo-storage-port)

Repository storage port.

Port to use when connecting to the storage (e.g. S3, Azure) endpoint (or host if specified).

default: 443
allowed: [1, 65535]
example: repo1-storage-port=9000

Deprecated Names: repo-azure-port, repo-s3-port

Repository Storage Tag Option (--repo-storage-tag)

Repository storage tag(s).

For an object store repository, such as S3, specify the tags to add to objects. Repeat this option to add multiple tags.

pgBackRest cannot change these tags. Before you run stanza-create, set them correctly to give the entire repository uniform tags.

example: repo1-storage-tag=key1=value1

Repository Storage Upload Chunk Size Option (--repo-storage-upload-chunk-size)

Repository storage upload chunk size.

Object stores, such as S3, support uploads in chunks for files too large to fit in memory. For smaller files, chunks also reduce the memory used for uploads.

Larger chunks usually improve performance because they reduce upload requests. More files can fit in a single request without division into chunks. However, larger chunks use more memory. Each process needs a chunk buffer, so a larger process-max value also increases total memory use.

Valid chunk sizes depend on the storage type and platform. For example, AWS S3 requires a minimum chunk size of 5MiB. To find minimum and maximum values, search for the term that matches your storage type. Use “part size” for AWS S3, “chunk size” for GCS, and “block size” for Azure.

By default, PostgreSQL creates files no larger than 1GiB. For larger files, pgBackRest increases the chunk size in increments, up to the allowed maximum, to complete the upload.

default (depending on repo-type):
    azure - 4MiB
    gcs - 4MiB
    s3 - 5MiB

allow range (depending on repo-type):
    azure - [4MiB, 1GiB]
    gcs - [4MiB, 1GiB]
    s3 - [5MiB, 1GiB]

example: repo1-storage-upload-chunk-size=16MiB

Repository Storage Certificate Verify Option (--repo-storage-verify-tls)

Repository storage certificate verify.

Enable or disable verification of the storage server TLS certificate, for example for S3 or Azure. Disable verification only for testing or other cases that use a self-signed certificate.

default: y
example: repo1-storage-verify-tls=n

Deprecated Names: repo-azure-verify-tls, repo-s3-verify-ssl, repo-s3-verify-tls

Create symlinks within the repository.

Create latest and tablespace symlinks. These mainly help with snapshot-based, in-place repository recovery, which is uncommon.

Most users probably do not need this feature. It remains enabled by default for compatibility. Disable it for Posix-like storage that cannot support symlinks.

default: y
example: repo1-symlink=n

Target Time for Repository Option (--repo-target-time)

Target time for repository.

Set the point in time at which commands read a repository on versioned storage. This lets you recover data deleted or corrupted by user error or malware.

S3, GCS, and Azure support versioned storage, but usually disable it by default. In addition to versioning, consider S3 object locking or GCS and Azure soft delete.

When you specify repo-target-time, you must also specify repo. Some repository types probably will not support versioning. Recovery usually targets one repository.

Storage timestamps must be <= the specified timestamp. pgBackRest truncates milliseconds from the specified timestamp.

example: repo-target-time=2024-08-08 12:12:12+00

Repository Type Option (--repo-type)

Type of storage used for the repository.

The following repository types are supported:

  • azure - Azure Blob Storage Service
  • cifs - Like posix, but disables links and directory fsyncs
  • gcs - Google Cloud Storage
  • posix - Posix-compliant file systems
  • s3 - AWS Simple Storage Service
  • sftp - Secure File Transfer Protocol

For an NFS mount used as a posix repository, follow the PostgreSQL filesystem rules. See Creating a Database Cluster - File Systems.

default: posix
example: repo1-type=cifs

Restore Options

The restore section defines settings used for restoring backups.

Archive Mode Option (--archive-mode)

Preserve or disable archiving on restored cluster.

Preserve or disable archiving on the restored cluster. Disable it when you must promote the cluster for work but it will not become the new primary. In that case, the cluster should not push WAL to the repository.

The following modes are supported:

  • off - disable archiving by setting archive_mode=off.
  • preserve - preserve current archive_mode setting.

NOTE: This option is not available on PostgreSQL < 12.

default: preserve
example: archive-mode=off

Exclude Database Option (--db-exclude)

Restore excluding the specified databases.

Restore excluded databases as sparse, zeroed files. This saves space while allowing PostgreSQL recovery. After recovery, you cannot access these databases, but you can remove them with drop database. Repeat --db-exclude to exclude multiple databases.

When combined with --db-include, --db-exclude applies only to the standard system databases: template0, template1, and postgres.

example: db-exclude=db_main

Include Database Option (--db-include)

Restore only specified databases.

Restore only selected databases. Restore other databases as sparse, zeroed files to save space while allowing PostgreSQL recovery. After recovery, you cannot access the other databases, but you can remove them with drop database.

NOTE:

Built-in databases (template0, template1, and postgres) are always restored unless you explicitly exclude them.

Repeat --db-include to include multiple databases.

See Restore Selected Databases for additional information and caveats.

example: db-include=db_main

Restore all symlinks.

By default, restore converts symlinks to regular files and directories in $PGDATA. Original symlink destinations might be unsafe on a different system. Enable this option to restore all symlinks as they were on the backup source system.

default: n
example: link-all=y

Modify the destination of a symlink.

Change a symlink destination file or path during a restore. Use this when the destination system has a different storage layout from the backup source.

example: link-map=pg_xlog=/data/xlog

Recovery Option (--recovery-option)

Set an option in postgresql.auto.conf or recovery.conf.

See Server Configuration for postgresql.auto.conf and recovery.conf options. Select your PostgreSQL version. You can repeat this option.

For PostgreSQL >= 12, pgBackRest writes options to postgresql.auto.conf. For earlier versions, it writes them to recovery.conf.

NOTE:

pgBackRest generates restore_command automatically. This option can override it, but use care because pgBackRest manages it for you. pgBackRest also generates target recovery options, such as recovery_target_name and recovery_target_time. Do not set those options here.

pgBackRest does not start PostgreSQL after it writes postgresql.auto.conf or recovery.conf. You can check or edit the file before you restart PostgreSQL manually.

example: recovery-option=primary_conninfo=db.mydomain.com

Tablespace Map Option (--tablespace-map)

Restore a tablespace into the specified directory.

Move a tablespace during restore. Use this when a replica has different tablespace locations or an upgraded system has different mount points.

pg_tablespace does not store tablespace locations, so you can move tablespaces freely. However, do not move a tablespace to data_directory; this can cause problems. For more information, see http://www.databasesoup.com/2013/11/moving-tablespaces.html.

example: tablespace-map=ts_01=/db/ts_01

Map All Tablespaces Option (--tablespace-map-all)

Restore all tablespaces into the specified directory.

By default, tablespaces return to their original locations. Use tablespace-map to change individual locations, or this option to move all tablespaces to one new directory. This helps with development or staging systems whose storage layout differs from the backup source.

Use the specified path as the parent directory for all restored tablespaces.

CAUTION:

pgBackRest cannot map tablespaces created after the backup starts. If you need mapping, take a new backup after creating a tablespace.

example: tablespace-map-all=/data/tablespace

Server Options

The server section defines options used for configuring the TLS server.

TLS Server Address Option (--tls-server-address)

TLS server address.

Set the IP address on which the server accepts client requests.

default: localhost
example: tls-server-address=*

TLS Server Authorized Clients Option (--tls-server-auth)

TLS server authorized clients.

The server verifies each client certificate. It also checks the certificate CN (Common Name) against the list configured with tls-server-auth.

To authorize a client CN for multiple stanzas, provide a comma-separated list to tls-server-auth. To authorize all stanzas, use tls-server-auth=client-cn=*. The client CN cannot contain wildcards.

example: tls-server-auth=client-cn=stanza1,stanza2

TLS Server Certificate Authorities Option (--tls-server-ca-file)

TLS server certificate authorities.

Checks that client certificates are signed by a trusted certificate authority.

example: tls-server-ca-file=/path/to/server.ca

TLS Server Certificate Option (--tls-server-cert-file)

TLS server certificate file.

The server sends this certificate to identify itself to the client.

example: tls-server-cert-file=/path/to/server.crt

TLS Server Key Option (--tls-server-key-file)

TLS server key file.

This key proves that the certificate owner sent the server certificate.

example: tls-server-key-file=/path/to/server.key

TLS Server Port Option (--tls-server-port)

TLS server port.

Set the port on which the server accepts client requests.

default: 8432
allowed: [1, 65535]
example: tls-server-port=8000

Stanza Options

A stanza configures backups for one PostgreSQL database cluster. Its section must define the cluster path. For a remote cluster, also define the host and user. Stanza-specific settings can override any global configuration section.

Indexing: Every pg- option has an index to support multiple PostgreSQL hosts. For one primary, use options such as pg1-path and pg1-port. For a standby, configure pg2- options on the repository host, such as pg2-host and pg2-path.

PostgreSQL Database Option (--pg-database)

PostgreSQL database.

Set the database name for PostgreSQL connections. The default is usually suitable, but some installations do not have this database.

For compatibility, pgBackRest ignores the PGDATABASE environment variable.

default: postgres
example: pg1-database=backupdb

PostgreSQL Host Option (--pg-host)

PostgreSQL host for operating remotely.

Use this option when the PostgreSQL host and repository host differ.

example: pg1-host=db.domain.com

Deprecated Name: db-host

PostgreSQL Host Certificate Authority File Option (--pg-host-ca-file)

PostgreSQL host certificate authority file.

Use a CA file other than the system default for connecting to the PostgreSQL host.

example: pg1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crt

PostgreSQL Host Certificate Authority Path Option (--pg-host-ca-path)

PostgreSQL host certificate authority path.

Use a CA path other than the system default for connecting to the PostgreSQL host.

example: pg1-host-ca-path=/etc/pki/tls/certs

PostgreSQL Host Certificate File Option (--pg-host-cert-file)

PostgreSQL host certificate file.

pgBackRest sends this certificate to the PostgreSQL host to prove the client identity.

example: pg1-host-cert-file=/path/to/client.crt

PostgreSQL Host Command Option (--pg-host-cmd)

PostgreSQL host pgBackRest command.

Set this option only when the pgBackRest command path differs between the local and PostgreSQL hosts. Otherwise, the PostgreSQL host uses the local command path.

default: [path of executed pgbackrest binary]
example: pg1-host-cmd=/usr/lib/backrest/bin/pgbackrest

Deprecated Name: db-cmd

PostgreSQL Host Configuration Option (--pg-host-config)

pgBackRest database host configuration file.

Set the PostgreSQL host configuration file location. This is necessary only when it differs from the local configuration file location.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE
example: pg1-host-config=/conf/pgbackrest/pgbackrest.conf

Deprecated Name: db-config

PostgreSQL Host Configuration Include Path Option (--pg-host-config-include-path)

pgBackRest database host configuration include path.

Set the PostgreSQL host configuration include path. This is necessary only when it differs from the local configuration include path.

default: CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH
example: pg1-host-config-include-path=/conf/pgbackrest/conf.d

PostgreSQL Host Configuration Path Option (--pg-host-config-path)

pgBackRest database host configuration path.

Set the PostgreSQL host configuration path. This is necessary only when it differs from the local configuration path.

default: CFGOPTDEF_CONFIG_PATH
example: pg1-host-config-path=/conf/pgbackrest

PostgreSQL Host Key File Option (--pg-host-key-file)

PostgreSQL host key file.

This key proves that the certificate owner sent the client certificate.

example: pg1-host-key-file=/path/to/client.key

PostgreSQL Host Port Option (--pg-host-port)

PostgreSQL host port when pg-host is set.

Use this option to specify a non-default port for the PostgreSQL host protocol.

NOTE:

When pg-host-type=ssh, pg-host-port has no default. The command specified by cmd-ssh supplies its configured port.

default (depending on pg-host-type):
    tls - 8432

allowed: [0, 65535]
example: pg1-host-port=25

Deprecated Name: db-ssh-port

PostgreSQL Host Protocol Type Option (--pg-host-type)

PostgreSQL host protocol type.

The following protocol types are supported:

  • ssh - Secure Shell.
  • tls - pgBackRest TLS server.
default: ssh
example: pg1-host-type=tls

PostgreSQL Host User Option (--pg-host-user)

PostgreSQL host logon user when pg-host is set.

This user owns the remote pgBackRest process and starts PostgreSQL connections. Use the PostgreSQL cluster owner, usually the default user postgres.

default: postgres
example: pg1-host-user=db_owner

Deprecated Name: db-user

PostgreSQL Path Option (--pg-path)

PostgreSQL data directory.

Use the data_directory value reported by PostgreSQL. Other sources can provide this value, but they might be unavailable during a restore or offline backup. Set it here as a precaution.

Each online backup compares pg-path with the value reported by PostgreSQL. Thus, this setting should stay current.

example: pg1-path=/data/db

Deprecated Name: db-path

PostgreSQL Port Option (--pg-port)

PostgreSQL port.

Set the PostgreSQL port. Most clusters use the default port, so this setting is usually unnecessary.

default: 5432
allowed: [0, 65535]
example: pg1-port=6543

Deprecated Name: db-port

PostgreSQL Socket Path Option (--pg-socket-path)

PostgreSQL unix socket path.

Set the Unix socket directory selected at PostgreSQL startup. pgBackRest searches the standard location for your OS automatically. Usually, set this option only if unix_socket_directories in postgresql.conf specifies another directory.

example: pg1-socket-path=/var/run/postgresql

Deprecated Name: db-socket-path

PostgreSQL Database User Option (--pg-user)

PostgreSQL database user.

Set the database user for PostgreSQL connections. If unset, pgBackRest uses the local OS user or PGUSER.

example: pg1-user=backupuser

6 - Release Notes

pgBackRest release history with detailed changelog for every version.

Introduction

pgBackRest release numbers have major and minor parts. A major release may break compatibility with the previous major release. However, v2 releases fully support v1 repositories and accept all v1 options. Minor releases can add features and bug fixes. They do not change the repository format and aim to preserve option names and behavior. See the v1 documentation.

A release can include “Additional Notes”. These cover only documentation or test-suite changes and do not directly affect the pgBackRest codebase.


Current Stable Release

v2.59.2 Release Notes

PostgreSQL 19beta4 Support

Released September 27, 2026

Bug Fixes:

  • Fix empty block map when file is truncated to zero during backup. (Reviewed by Douglas J Hunley. Reported by JPCOSTA78.)
  • Disable read retry when filters are passed to the driver. (Reviewed by Douglas J Hunley. Reported by megamaced.)
  • Fix pagination of S3 version listing. (Reviewed by Douglas J Hunley, guruguruguru. Reported by guruguruguru.)
  • Set the Azure version header for SAS authentication. (Reviewed by Douglas J Hunley. Reported by Florian Helmberger.)
  • Fix async archive-push stalling on a zero-size backup history file. (Fixed by Andrew Kroh. Reviewed by David Steele, Douglas J Hunley.)
  • Fix annotate command on a remote encrypted repository. (Fixed by Douglas J Hunley. Reviewed by David Steele.)

Features:

  • PostgreSQL 19beta4 support.

Stable Releases

v2.59.1 Release Notes

PostgreSQL 19beta3 Support

Released August 17, 2026

Bug Fixes:

  • Fix hang when the chunk buffer is smaller than the input buffer. (Reviewed by Andrew Pogrebnoi, Douglas J Hunley. Reported by crajac66.)
  • Compare a new backup label only against its own full backup set. (Reviewed by Douglas J Hunley. Reported by Anton Glushakov.)
  • Fix source archives generated by GitHub missing files required to build. (Reported by aardvarkzed.)

Features:

  • PostgreSQL 19beta3 support. (Contributed by Lardière Sébastien. Reviewed by David Steele.)

Documentation Improvements:

  • Document exception for dots in S3 bucket names when repo-s3-uri-style=path.
  • Remove explicit hot_standby configuration from user guide.

v2.59.0 Release Notes

PostgreSQL 19beta2 Support

Released July 20, 2026

NOTE TO PACKAGERS: A new distribution tarball simplifies builds with pregenerated HTML documentation, a man page, and code. Each release includes a pgbackrest-{version}.tar.gz asset. See its README.md for details. Use this tarball to avoid the additional code-generation tools that future releases require. See New Distribution Tarball.

NOTE TO PACKAGERS: libsystemd is a new optional dependency.

IMPORTANT NOTE: Starting with this release, only restore can run as root by default. Use allow-root for other commands, although this is not recommended.

Bug Fixes:

  • Fix expire removing a backup in progress on another host. (Reviewed by Douglas J Hunley. Reported by Dmitrii.)
  • Fix archive-push-queue-max not enforced when a WAL file errors. (Reviewed by Stefan Fercot. Reported by vut12.)
  • Fix async archive-get failure during recovery across a timeline switch. (Reviewed by Douglas J Hunley. Reported by Jimmy Yih.)
  • Fix potential buffer overrun in error module. (Fixed by Christophe Pettus. Reviewed by David Steele.)
  • Fix use-after-free of parallel protocol client. (Reviewed by Douglas J Hunley. Reported by Georgy Shelkovy.)
  • Fix heap overflow when a pg option is set without pg1. (Reviewed by Douglas J Hunley. Reported by Naveen.)

Features:

  • PostgreSQL 19beta2 support. (Reviewed by Stefan Fercot.)
  • Add archive-expire-before option to clean up WAL archive. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Add batch delete for Azure storage. (Reviewed by Douglas J Hunley, Crispy.)
  • Add support for S3 Outposts. (Contributed by Shiva Kumar Ambigi. Reviewed by David Steele, Roberto Mello.)
  • Add S3 process authentication. (Reviewed by Andrew Charlton. Suggested by Andrew Charlton.)

Improvements:

  • Reconnect SFTP storage after the server drops an idle connection. (Reviewed by Stefan Fercot. Suggested by mustafa0x, tisserat.)
  • Add user/group caching for faster manifest build. (Contributed by Gunnar Lindholm. Reviewed by David Steele.)
  • Add per-repo backup progress to info command output. (Contributed by Will Morland. Reviewed by David Steele, Stefan Fercot.)
  • Add backup.info checks to verify command. (Contributed by Denis Garsh. Reviewed by David Steele, Douglas J Hunley.)
  • Allow the S3 STS endpoint to be configured. (Contributed by Simon Gratton. Reviewed by David Steele.)
  • Add archive-push-batch-size to limit WAL pushed per asynchronous run. (Reviewed by Stefan Fercot.)
  • Exit async archive-push on first error. (Reviewed by Stefan Fercot. Suggested by Lardière Sébastien.)
  • Harden HTTP chunked response parsing. (Contributed by Shubham. Reviewed by David Steele.)
  • Error when running as root unless allow-root is enabled. (Reviewed by Douglas J Hunley.)
  • Fewer binary searches when building manifest. (Contributed by Gunnar Lindholm. Reviewed by David Steele.)
  • Improve seek performance during block incremental delta restore. (Reviewed by David Christensen, Douglas J Hunley.)
  • Bundle backup files in order rather than scanning for a better fit. (Reviewed by Stefan Fercot.)
  • Report the underlying error when a query fails to complete. (Reviewed by Andrew Pogrebnoi. Suggested by Marco Fontana.)
  • Report the actual error when an S3 credential request fails. (Reviewed by Douglas J Hunley. Suggested by Mitchell Grice.)
  • Report archive-push spool path errors to the PostgreSQL log. (Reviewed by Douglas J Hunley. Suggested by Don Seiler.)
  • Hint that pgBackRest may be out of date when a version is unsupported.
  • Add systemd notify integration. (Contributed by Andrew Jackson. Reviewed by David Steele.)
  • Suppress unused parameter errors in meson compiler probes. (Contributed by Jörg Plate. Reviewed by David Steele.)
  • C11 is now the minimum C standard. (Reviewed by Mohammad Ali Nazir Kosar.)

Documentation Improvements:

  • Make stanza option internal for the repo-* commands. (Reviewed by Stefan Fercot.)
  • Document that info reads encryption settings from global section. (Reviewed by Stefan Fercot. Suggested by Ron Johnson.)
  • Document that expire-auto uses the backup command configuration. (Reviewed by Stefan Fercot. Suggested by Lardière Sébastien.)
  • Document adjusting the logrotate su directive for a dedicated user. (Reviewed by Douglas J Hunley. Suggested by lkanbus.)
  • Document that end-of-line comments are not supported in config files. (Reviewed by Douglas J Hunley. Suggested by Alex Richman.)

Test Suite Improvements:

  • Fix Alpine group conflicts in CI containers. (Contributed by Artur Zakirov. Reviewed by David Steele.)

v2.58.0 Release Notes

Object Storage Improvements

Released January 19, 2026

IMPORTANT NOTE: This release increased the minimum repo-storage-upload-chunk-size values to the minimums permitted by storage vendors.

Bug Fixes:

  • Fix deadlock due to logging in signal handler. (Fixed by Maxim Michkov. Reviewed by David Steele.)

Features:

  • HTTP support for S3, GCS, and Azure. (Contributed by Will Morland. Reviewed by David Steele.)
  • Allow expiration of oldest full backup regardless of current retention. (Contributed by Stefan Fercot. Reviewed by David Steele. Suggested by Ron Johnson.)
  • Support for Azure managed identities. (Contributed by Moiz Ibrar, Matthew Mols. Reviewed by David Steele.)
  • Experimental support for S3 EKS pod identity. (Contributed by Pierre BOUTELOUP. Reviewed by David Steele.)
  • Allow configuration of TLS cipher suites. (Contributed by Gunnar “Nick” Bluth. Reviewed by David Steele.)
  • Allow process priority to be set. (Reviewed by Douglas J Hunley.)

Improvements:

  • Allow dots in S3 bucket names when using path-style URIs. (Contributed by Joakim Hindersson. Reviewed by David Steele.)
  • Require TLS >= 1.2 unless verification is disabled. (Reviewed by Douglas J Hunley, Gunnar “Nick” Bluth.)
  • Dynamically size S3/GCS/Azure chunks for large uploads. (Reviewed by Douglas J Hunley. Suggested by Timothée Peignier.)
  • Optimize S3/GCS/Azure chunk size for small files. (Reviewed by Douglas J Hunley.)
  • Remove support for PostgreSQL 9.5. (Reviewed by Douglas J Hunley.)
  • Improve logging of default for options with an unresolved dependency. (Reviewed by Stefan Fercot.)

Documentation Improvements:

  • Remove explicit max_wal_senders/wal_level configuration from user guide. (Suggested by Jamie Nguyen.)
  • Clarify that bundling is useful for filesystems with large block sizes. (Suggested by Ron Johnson.)

v2.57.0 Release Notes

Suppress Repository Symlinks

Released October 18, 2025

Bug Fixes:

  • Unnest HTTP/TLS/socket timeouts. (Reviewed by David Christensen.)
  • Fix possible segfault in page checksum error message. (Fixed by Zsolt Parragi. Reviewed by David Steele.)

Features:

  • Add repo-symlink option to suppress creation of repository symlinks. (Reviewed by Douglas J Hunley. Suggested by Ron Johnson.)

Improvements:

  • Add HTTP retries for 408 and 429 errors. (Reviewed by David Christensen.)

v2.56.0 Release Notes

Progress Info Improvements

Released July 21, 2025

Bug Fixes:

  • Fix issue with adhoc expiration when no backups in a repository. (Reviewed by Stefan Fercot. Reported by Anup Gupta.)

Features:

  • Add restore progress to info command output. (Contributed by Denis Garsh, Maxim Michkov. Reviewed by David Steele.)
  • Add progress-only detail level for info command output. (Contributed by Denis Garsh. Reviewed by David Steele, Stefan Fercot.)

Improvements:

  • Retry failed reads on object stores. (Reviewed by David Christensen.)
  • Fix defaults in command-line help. (Reviewed by David Christensen, Chris Bandy.)

Documentation Improvements:

  • Describe discrete option values in a list where appropriate. (Contributed by Anton Kurochkin. Reviewed by David Steele.)
  • Fix “less than” in help output for archive-mode option. (Contributed by Anton Kurochkin. Reviewed by David Steele.)

v2.55.1 Release Notes

Bug Fixes

Released May 5, 2025

Bug Fixes:

  • Revert “calculate content-md5 on S3 only when required”. (Reviewed by David Christensen. Reported by Frank Brendel.)
  • Fix lower bounds checking for option keys. (Reviewed by David Christensen, Wolfgang Walther. Reported by Wolfgang Walther.)

v2.55.0 Release Notes

Verification Improvements and PostgreSQL 18 Support

Released April 21, 2025

Bug Fixes:

  • Fix block incremental restore issue on non-default repository. (Reviewed by David Christensen, Aleksander Łukasz. Reported by Aleksander Łukasz.)
  • Do not set recovery_target_timeline=current for PostgreSQL < 12. (Reviewed by Stefan Fercot.)
  • Fix expire archive range logging. (Reviewed by Stefan Fercot. Reported by Aleš Zelený.)
  • Fix error reporting for queries with no results. (Reviewed by Stefan Fercot. Reported by Susantha Bathige.)

Features:

  • Verify recovery target timeline. (Reviewed by Stefan Fercot.)
  • Allow verification of a specified backup. (Contributed by Maxim Michkov. Reviewed by David Steele.)
  • Add support for S3/GCS requester pays. (Contributed by Timothée Peignier. Reviewed by David Steele.)
  • PostgreSQL 18 support. (Reviewed by Stefan Fercot.)
  • Allow connections to PostgreSQL on abstract domain sockets. (Reviewed by Chris Bandy. Suggested by Chris Bandy.)
  • Add numeric output to version command. (Contributed by Stefan Fercot. Reviewed by David Steele.)

Improvements:

  • Allow backup command to operate on remote repositories. (Reviewed by Stefan Fercot.)
  • Use lz4 for protocol compression. (Reviewed by Stefan Fercot.)
  • Calculate content-md5 on S3 only when required. (Reviewed by David Christensen.)
  • Warn when a value for a multi-key option is overwritten. (Reviewed by David Christensen, Stefan Fercot.)
  • Add detail logging for expired archive path. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Remove support for PostgreSQL 9.4. (Reviewed by Stefan Fercot.)
  • Remove autoconf/make build. (Reviewed by David Christensen.)

Documentation Improvements:

  • Fix documentation for specifying multiple stanzas with tls-server-auth. (Reviewed by David Christensen, Stefan Fercot. Suggested by Terry MacAndrew.)
  • Clarify incremental backup expiration. (Reviewed by Stefan Fercot.)
  • Clarify requirement for local/remote pgBackRest versions to match. (Contributed by Greg Clough. Reviewed by David Steele.)
  • Add FAQ about exporting self-contained cluster. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Caveat --tablespace-map-all regarding tablespace creation. (Reviewed by Stefan Fercot, Christophe Courtois. Suggested by Christophe Courtois.)
  • Clarify behavior of --repo-retention-full-type. (Reviewed by Antoine Beaupré. Suggested by Antoine Beaupré.)
  • Change --process-max recommendation for object stores to --repo-bundle. (Reviewed by Stefan Fercot.)
  • Update unix_socket_directory to unix_socket_directories. (Contributed by hyunkyu han. Reviewed by David Steele.)
  • Recommend not placing spool-path within pg_xlog/pg_wal. (Reviewed by Martín Marqués, Don Seiler. Suggested by Martín Marqués.)

v2.54.2 Release Notes

Bug Fix

Released January 20, 2025

Bug Fixes:

  • Fix issue after disabling bundling with block incremental enabled. (Reviewed by David Christensen.)

Documentation Improvements:

  • Clarify behavior of multiple configuration files. (Reviewed by Paul Bierly. Suggested by Paul Bierly.)

v2.54.1 Release Notes

Bug Fix

Released December 16, 2024

Bug Fixes:

  • Fix issue with version/help commands attempting to load pgbackrest.conf. (Reviewed by Stefan Fercot. Reported by Bradford Boyle, Julian.)

Test Suite Improvements:

  • Stabilize async archiving in integration tests. (Contributed by Viktor Kurilko. Reviewed by David Steele.)

v2.54.0 Release Notes

Target Time for Versioned Storage

Released October 21, 2024

NOTE TO PACKAGERS: This was the last feature release with autoconf/make support. Migrate to meson. Any 2.54.X patch releases will still support autoconf/make.

Bug Fixes:

  • Fix PostgreSQL query performance for large datasets. (Fixed by Thibault Vincent, David Steele. Reviewed by David Christensen, Antoine Millet. Reported by Antoine Millet.)

Features:

  • Allow repositories on versioned storage to be read at a target time. (Reviewed by Stefan Fercot, David Christensen.)
  • Allow requested standby backup to proceed with no standby. (Reviewed by Stefan Fercot.)

Improvements:

  • Summarize backup reference list for info command text output. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Refresh web-id token for each S3 authentication. (Contributed by Brent Graveland. Reviewed by David Steele.)
  • Correctly display current values for indexed options in help. (Reviewed by David Christensen.)
  • Save backup.info only when contents have changed. (Reviewed by Stefan Fercot.)
  • Remove limitation on reading files in parallel during restore. (Reviewed by David Christensen.)
  • Improve SFTP error messages. (Contributed by Reid Thompson. Reviewed by David Steele.)

Documentation Features:

  • Add performance tuning section to user guide. (Reviewed by Stefan Fercot.)

Documentation Improvements:

  • Clarify source for data_directory. (Contributed by Stefan Fercot. Reviewed by David Steele. Suggested by Matthias.)
  • Better logic for deciding when a summary should be lower-cased. (Suggested by Daniel Westermann.)

v2.53.1 Release Notes

PostgreSQL 17 Support

Released August 19, 2024

Bug Fixes:

  • Fix permissions when restore run as root user. (Reviewed by Stefan Fercot. Reported by Will M.)
  • Fix segfault on delayed connection errors. (Reviewed by David Christensen. Reported by Anton Glushakov.)
  • Skip local repository duplicate check for SFTP. (Fixed by Reid Thompson. Reviewed by David Steele. Reported by Anton Kurochkin.)

Improvements:

  • PostgreSQL 17 support.

v2.53 Release Notes

Concurrent Backups

Released July 22, 2024

IMPORTANT NOTE: This release changed the log-level-stderr default from warn to off. This simplifies error capture when only stdout is redirected. To keep the previous behavior, set log-level-stderr=warn.

NOTE TO PACKAGERS: The meson build now requires the lz4 library.

NOTE TO PACKAGERS: The meson build now requires compiler support for __builtin_clzl() and __builtin_bswap64().

Bug Fixes:

  • Fix SFTP renaming failure when file already exists. (Fixed by Reid Thompson. Reviewed by David Steele. Reported by ahmed112212.)

Features:

  • Allow backups to run concurrently on different repositories. (Reviewed by Reid Thompson, Stefan Fercot.)
  • Support IP-based SANs for TLS certificate validation. (Contributed by David Christensen. Reviewed by David Steele.)

Improvements:

  • Default log-level-stderr option to off. (Reviewed by Greg Sabino Mullane, Stefan Fercot.)
  • Allow alternative WAL segment sizes for PostgreSQL ≤ 10. (Contributed by Viktor Kurilko. Reviewed by David Steele.)
  • Add hint to check SFTP authorization log. (Contributed by Vitalii Zurian. Reviewed by Reid Thompson, David Steele.)

Documentation Improvements:

  • Clarify archive-push multi-repo behavior. (Reviewed by Stefan Fercot.)

v2.52.1 Release Notes

Bug Fix

Released June 25, 2024

Bug Fixes:

  • Fix issue with files larger on the replica than on the primary. (Reviewed by Stefan Fercot. Reported by Nicolas Lassimonne.)

v2.52 Release Notes

PostgreSQL 17beta1 Support

Released May 27, 2024

NOTE TO PACKAGERS: This release made meson the pgBackRest build system. The autoconf/make build would receive no new features and was scheduled for removal after a few releases.

Features:

  • Add GCS batch delete support. (Reviewed by Reid Thompson.)
  • S3 SSE-C encryption support. (Reviewed by Tim Jones. Suggested by Tim Jones.)
  • PostgreSQL 17beta1 support. (Reviewed by Stefan Fercot.)

Improvements:

  • Allow explicit disabling of optional dependencies in meson builds. (Contributed by Michael Schout. Reviewed by David Steele.)
  • Dynamically find python in meson build. (Contributed by Michael Schout. Reviewed by David Steele.)
  • Tag pgbackrest build target in meson as installable. (Contributed by Bradford Boyle. Reviewed by David Steele.)

Documentation Improvements:

  • Update start/stop documentation to reflect actual functionality. (Reviewed by Stefan Fercot.)

v2.51 Release Notes

Meson Build System

Released March 25, 2024

Bug Fixes:

  • Skip zero-length files for block incremental delta restore. (Reviewed by Sebastian Krause, René Højbjerg Larsen. Reported by Sebastian Krause.)
  • Fix performance regression in storage list. (Reviewed by Stephen Frost. Reported by Maksym Boguk.)
  • Fix progress logging when file size changes during backup. (Reviewed by Stephen Frost. Reported by samkingno.)

Improvements:

  • Improved support for dual stack connections. (Reviewed by Stephen Frost. Suggested by Timothée Peignier.)
  • Make meson the primary build system. (Reviewed by Stephen Frost.)
  • Detect files that have not changed during non-delta incremental backup. (Reviewed by Stephen Frost.)
  • Prevent invalid recovery when backup_label removed. (Reviewed by Stephen Frost.)
  • Improve archive-push WAL segment queue handling. (Reviewed by Stephen Frost.)
  • Limit resume functionality to full backups. (Reviewed by Stephen Frost, Stefan Fercot.)
  • Update resume functionality for block incremental. (Reviewed by Stephen Frost.)
  • Allow --version and --help for version and help. (Reviewed by Greg Sabino Mullane. Suggested by Greg Sabino Mullane.)
  • Add detailed backtrace to autoconf/make build. (Reviewed by Stephen Frost.)

Documentation Improvements:

  • Update references to recovery.conf. (Reviewed by Stefan Fercot. Suggested by Stephen Frost.)

v2.50 Release Notes

Performance Improvements and Bug Fixes

Released January 22, 2024

Bug Fixes:

  • Fix short read in block incremental restore. (Reviewed by Stephen Frost, Brent Graveland. Reported by Adol Rodriguez, Brent Graveland.)
  • Fix overflow suppressing backup progress in info output. (Fixed by Robert Donovan. Reviewed by Joe Wildish.)

Improvements:

  • Preserve partial files during block incremental delta restore. (Reviewed by Stephen Frost.)
  • Add support for alternate compile-time page sizes. (Contributed by Viktor Kurilko. Reviewed by David Steele.)
  • Skip files truncated during backup when bundling. (Contributed by Georgy Shelkovy. Reviewed by David Steele.)
  • Improve SFTP storage error messages. (Contributed by Reid Thompson. Reviewed by David Steele.)

v2.49 Release Notes

Remove PostgreSQL 9.3 Support

Released November 27, 2023

Bug Fixes:

  • Fix regression in retries. (Reviewed by Stephen Frost. Reported by Norman Adkins, Tanel Suurhans, Jordan English, Timothée Peignier.)
  • Fix recursive path remove in SFTP storage driver. (Fixed by Reid Thompson. Reviewed by Stephen Frost. Reported by Luc.)

Improvements:

  • Remove support for PostgreSQL 9.3. (Reviewed by Stephen Frost.)

Documentation Features:

  • Document maintainer options. (Reviewed by Stefan Fercot.)
  • Update point-in-time recovery documentation for PostgreSQL >= 13.

Test Suite Improvements:

  • Allow config/load unit test to run without libssh2 installed. (Contributed by Reid Thompson. Reviewed by David Steele. Suggested by Wu Ning.)

v2.48 Release Notes

Repository Storage Tags

Released September 25, 2023

Bug Fixes:

  • Fix issue restoring block incremental without a block list. (Reviewed by Stephen Frost, Burak Yurdakul. Reported by Burak Yurdakul.)

Features:

  • Add --repo-storage-tag option to create object tags. (Reviewed by Stephen Frost, Stefan Fercot, Timothée Peignier.)
  • Add known hosts checking for SFTP storage driver. (Contributed by Reid Thompson. Reviewed by Stephen Frost, David Steele.)
  • Support for dual stack connections. (Reviewed by Stephen Frost.)
  • Add backup size completed/total to info command JSON output. (Contributed by Stefan Fercot. Reviewed by David Steele.)

Improvements:

  • Multi-stanza check command. (Reviewed by Stephen Frost.)
  • Retry reads of pg_control until checksum is valid. (Reviewed by Stefan Fercot, Stephen Frost.)
  • Optimize WAL segment check after successful backup. (Reviewed by Stephen Frost.)
  • Improve GCS multi-part performance. (Reviewed by Reid Thompson.)
  • Allow archive-get command to run when stanza is stopped. (Reviewed by Tom Swartz, David Christensen, Reid Thompson.)
  • Accept leading tilde in paths for SFTP public/private keys. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Reload GCS credentials before renewing authentication token. (Reviewed by Stephen Frost. Suggested by Daniel Farina.)

Documentation Bug Fixes:

  • Fix configuration reference example for the tls-server-address option. (Fixed by Hartmut Goebel. Reviewed by David Steele.)
  • Fix command reference example for the filter option.

Test Suite Improvements:

  • Allow storage/sftp unit test to run without libssh2 installed. (Contributed by Reid Thompson. Reviewed by David Steele. Suggested by Wu Ning.)

v2.47 Release Notes

Performance Improvements and Bug Fixes

Released July 24, 2023

Bug Fixes:

  • Preserve block incremental info in manifest during delta backup. (Reviewed by Stephen Frost. Reported by Francisco Miguel Biete Banon.)
  • Fix block incremental file names in verify command. (Reviewed by Reid Thompson. Reported by Francisco Miguel Biete Banon.)
  • Fix spurious automatic delta backup on backup from standby. (Reviewed by Stephen Frost. Reported by krmozejko, Don Seiler.)
  • Skip recovery.signal for PostgreSQL >= 12 when recovery type=none. (Reviewed by Stefan Fercot. Reported by T.Anastacio.)
  • Fix unique label generation for diff/incr backup. (Fixed by Andrey Sokolov. Reviewed by David Steele.)
  • Fix time-based archive expiration when no backups are expired. (Reviewed by Stefan Fercot.)

Improvements:

  • Improve performance of SFTP storage driver. (Contributed by Stephen Frost, Reid Thompson. Reviewed by David Steele.)
  • Add timezone offset to info command date/time output. (Reviewed by Stefan Fercot, Philip Hurst. Suggested by Philip Hurst.)
  • Centralize error handling for unsupported features. (Reviewed by Stefan Fercot.)

Documentation Improvements:

  • Clarify preference to install from packages in the user guide. (Reviewed by Stefan Fercot. Suggested by dr-kd.)

v2.46 Release Notes

Block Incremental Backup and SFTP Storage

Released May 22, 2023

Features:

  • Block incremental backup. (Reviewed by John Morris, Stephen Frost, Stefan Fercot.)
  • SFTP support for repository storage. (Contributed by Reid Thompson. Reviewed by Stephen Frost, David Steele.)
  • PostgreSQL 16 support. (Reviewed by Stefan Fercot.)

Improvements:

  • Allow page header checks to be skipped. (Reviewed by David Christensen. Suggested by David Christensen.)
  • Avoid chown() on recovery files during restore. (Reviewed by Stefan Fercot, Marcelo Henrique Neppel. Suggested by Marcelo Henrique Neppel.)
  • Add error retry detail for HTTP retries.

Documentation Improvements:

  • Add warning about using recovery type=none. (Reviewed by Stefan Fercot.)
  • Add note about running stanza-create on already-created repositories.

v2.45 Release Notes

Block Incremental Backup (BETA)

Released March 20, 2023

Bug Fixes:

  • Skip writing recovery.signal by default for restores of offline backups. (Reviewed by Stefan Fercot. Reported by Marcel Borger.)

Features:

  • Block incremental backup (BETA). (Reviewed by John Morris, Stephen Frost, Stefan Fercot.)

Improvements:

  • Keep only one all-default group index. (Reviewed by Stefan Fercot.)

Documentation Improvements:

  • Add explicit instructions for upgrading between 2.x versions. (Contributed by Christophe Courtois. Reviewed by David Steele.)
  • Remove references to SSH made obsolete when TLS was introduced.

v2.44 Release Notes

Remove PostgreSQL 9.0/9.1/9.2 Support

Released January 30, 2023

Improvements:

  • Remove support for PostgreSQL 9.0/9.1/9.2. (Reviewed by Stefan Fercot.)
  • Restore errors when no backup matches the current version of PostgreSQL. (Contributed by Stefan Fercot. Reviewed by David Steele. Suggested by Soulou.)
  • Add compress-level range checking for each compress-type. (Reviewed by Stefan Fercot. Suggested by gkleen, ViperRu.)

Documentation Improvements:

  • Add warning about enabling “hierarchical namespace” on Azure storage. (Reviewed by Stefan Fercot. Suggested by Vojtech Galda, Pluggi, asjonos.)
  • Add replacement for linefeeds in monitoring example. (Reviewed by Stefan Fercot. Suggested by rudonx, gmustdie, Ivan Shelestov.)
  • Clarify target-action behavior on various PostgreSQL versions. (Contributed by Chris Bandy. Reviewed by David Steele, Anton Kurochkin, Stefan Fercot. Suggested by Anton Kurochkin, Chris Bandy.)
  • Updates and clarifications to index page. (Reviewed by Stefan Fercot.)
  • Add dark mode to the website. (Suggested by Stephen Frost.)

v2.43 Release Notes

Bug Fix

Released November 28, 2022

Bug Fixes:

  • Fix missing reference in diff/incr backup. (Reviewed by Stefan Fercot. Reported by Marcel Borger, ulfedf, jaymefSO.)

Improvements:

  • Add hint when an option is specified without an index. (Reviewed by Stefan Fercot.)

v2.42 Release Notes

Bug Fixes

Released November 22, 2022

Bug Fixes:

  • Fix memory leak in file bundle backup/restore. (Reviewed by John Morris, Oscar. Reported by Oscar.)
  • Fix protocol error on short read of remote file. (Reviewed by Stephen Frost.)

Improvements:

  • Do not store references for zero-length files when bundling. (Reviewed by Stefan Fercot.)
  • Use more generic descriptions for pg_start_backup()/pg_stop_backup(). (Reviewed by Greg Sabino Mullane, David Christensen. Suggested by Greg Sabino Mullane.)

Test Suite Improvements:

  • Update test.pl --psql-bin option to match command-line help. (Contributed by Koshi Shibagaki. Reviewed by David Steele.)

v2.41 Release Notes

Backup Annotations

Released September 19, 2022

Bug Fixes:

  • Fix incorrect time expiration being used for non-default repositories. (Reviewed by Stefan Fercot. Reported by Adam Brusselback.)
  • Fix issue when listing directories recursively with a filter. (Reviewed by Stephen Frost. Reported by Efremov Egor.)

Features:

  • Backup key/value annotations. (Contributed by Stefan Fercot. Reviewed by David Steele. Suggested by Adam Berlin.)

Improvements:

  • Support --set in JSON output for info command. (Contributed by Stefan Fercot. Reviewed by David Steele. Suggested by Anton Kurochkin.)
  • Allow upload chunk size to be configured for object stores. (Reviewed by Stefan Fercot. Suggested by Anton Glushakov.)
  • Update archive.info timestamps after a successful backup. (Reviewed by Stefan Fercot. Suggested by Alex Richman.)
  • Move standby timeline check after checkpoint. (Reviewed by Stefan Fercot, Keith Fiske. Suggested by Keith Fiske.)
  • Improve warning message on backup resume. (Suggested by Cynthia Shang.)

Documentation Improvements:

  • Add absolute path for kill in pgbackrest.service. (Suggested by Don Seiler.)

v2.40 Release Notes

OpenSSL 3 Support

Released July 18, 2022

NOTE TO PACKAGERS: This release added an experimental meson build. At this time, packagers should continue to use autoconf/make.

Improvements:

  • OpenSSL 3 support. (Reviewed by Stephen Frost.)
  • Create snapshot when listing contents of a path. (Reviewed by John Morris, Stephen Frost.)
  • Force target-timeline=current when restore type=immediate. (Reviewed by Stephen Frost.)
  • Truncate files during delta restore when they are larger than expected. (Reviewed by Stephen Frost.)
  • Disable incremental manifest save when resume=n. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Set backup percent complete to zero before copy start. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Use S3 IsTruncated flag to determine list continuation. (Reviewed by John Morris, Soulou. Suggested by Christian Montagne.)

Documentation Bug Fixes:

  • Skip internal options in the configuration reference. (Reported by Francisco Miguel Biete Banon.)

Documentation Improvements:

  • Add link to PostgreSQL configuration in repository host section. (Reviewed by Stefan Fercot. Suggested by Julien Cigar.)

Test Suite Improvements:

  • Add experimental Meson build. (Reviewed by Eli Schwartz, Sam Bassaly.)
  • Allow any path to be passed to the --test-path option. (Contributed by Andrey Sokolov. Reviewed by David Steele.)
  • Fix compile error when DEBUG_EXEC_TIME is defined without DEBUG. (Contributed by Andrey Sokolov. Reviewed by David Steele.)

v2.39 Release Notes

Verify and File Bundling

Released May 16, 2022

Bug Fixes:

  • Fix error thrown from FINALLY() causing an infinite loop. (Reviewed by Stephen Frost.)
  • Error on all lock failures except another process holding the lock. (Reviewed by Reid Thompson, Geir Råness. Reported by Geir Råness.)

Features:

  • Backup file bundling for improved small file support. (Reviewed by Reid Thompson, Stefan Fercot, Chris Bandy.)
  • Verify command to validate the contents of a repository. (Contributed by Cynthia Shang, Reid Thompson. Reviewed by David Steele, Stefan Fercot.)
  • PostgreSQL 15 support. (Reviewed by Stefan Fercot.)
  • Show backup percent complete in info output. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Auto-select backup for restore command --type=lsn. (Contributed by Reid Thompson. Reviewed by Stefan Fercot, David Steele.)
  • Suppress existing WAL warning when archive-mode-check is disabled. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Add AWS IMDSv2 support. (Contributed by Nuno Pires. Reviewed by David Steele.)

Improvements:

  • Allow repo-hardlink option to be changed after full backup. (Reviewed by Reid Thompson.)
  • Increase precision of percent complete logging for backup and restore. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Improve path validation for repo-* commands. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Improve stop command to honor stanza option. (Contributed by Reid Thompson. Reviewed by David Steele. Suggested by ragaoua.)
  • Improve error message for invalid repo-azure-key. (Contributed by Reid Thompson. Reviewed by David Steele. Suggested by Seth Daniel.)
  • Add hint to check the log on archive-get/archive-push async error. (Reviewed by Reid Thompson.)
  • Add ClockError for unexpected clock skew and timezone changes. (Reviewed by Greg Sabino Mullane, Stefan Fercot. Suggested by Greg Sabino Mullane.)
  • Strip extensions from history manifest before showing in error message. (Reviewed by Stefan Fercot.)
  • Add user:group to lock permission error. (Reviewed by Reid Thompson.)

Documentation Bug Fixes:

  • Fix incorrect reference to stanza-update in the user guide. (Fixed by Abubakar Mohammed. Reviewed by David Steele.)
  • Fix example for repo-gcs-key-type option in configuration reference. (Reviewed by Reid Thompson.)
  • Fix tls-server-auth example and add clarifications. (Reviewed by Reid Thompson.)

Documentation Improvements:

  • Simplify messaging around supported versions in the documentation. (Reviewed by Stefan Fercot, Reid Thompson, Greg Sabino Mullane.)
  • Add option type descriptions. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Add FAQ about backup types and restore speed. (Contributed by David Christensen. Reviewed by Reid Thompson.)
  • Document required base branch for pull requests. (Contributed by David Christensen. Reviewed by Reid Thompson.)

v2.38 Release Notes

Minor Bug Fixes and Improvements

Released March 6, 2022

IMPORTANT NOTE: Starting with this release, info reports repository size entirely from the data pgBackRest writes to storage. Earlier versions could sometimes detect additional storage compression. This is no longer supported.

Bug Fixes:

  • Retry errors in S3 batch file delete. (Reviewed by Reid Thompson. Reported by Alex Richman.)
  • Allow case-insensitive matching of HTTP connection header values. (Reviewed by Reid Thompson. Reported by Rémi Vidier.)

Features:

  • Add support for AWS S3 server-side encryption using KMS. (Contributed by Christoph Berg. Reviewed by David Steele, Tharindu Amila.)
  • Add archive-missing-retry option. (Reviewed by Stefan Fercot.)
  • Add backup type filter to info command. (Contributed by Stefan Fercot. Reviewed by David Steele.)

Improvements:

  • Retry on page validation failure during backup. (Reviewed by Stephen Frost, David Christensen.)
  • Handle TLS servers that do not close connections gracefully. (Reviewed by Rémi Vidier, David Christensen, Stephen Frost.)
  • Add backup LSNs to info command output. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Automatically strip trailing slashes for repo-ls paths. (Contributed by David Christensen. Reviewed by David Steele.)
  • Do not retry fatal errors. (Reviewed by Reid Thompson.)
  • Remove support for PostgreSQL 8.3/8.4. (Reviewed by Reid Thompson, Stefan Fercot.)
  • Remove logic that tried to determine additional file system compression. (Reviewed by Reid Thompson, Stefan Fercot.)

Documentation Bug Fixes:

  • Move repo options in TLS documentation to the global section. (Reported by Anton Kurochkin.)
  • Remove unused backup-standby option from stanza commands. (Reported by Stefan Fercot.)
  • Fix typos in help and release notes. (Fixed by Daniel Gustafsson. Reviewed by David Steele.)

Documentation Improvements:

  • Add aliveness check to systemd service configuration. (Suggested by Yogesh Sharma.)
  • Add FAQ explaining WAL archive suffix. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Note that replications slots are not restored. (Contributed by Reid Thompson. Reviewed by David Steele, Stefan Fercot. Suggested by Christophe Courtois.)

v2.37 Release Notes

TLS Server

Released January 3, 2022

IMPORTANT NOTE: In this release, restore reports an error if no backup matches a specified time target. Previously, it logged a warning.

Bug Fixes:

  • Fix restore delta link mapping when path/file already exists. (Reviewed by Reid Thompson. Reported by Younes Alhroub.)
  • Fix socket leak on connection retries. (Reviewed by Reid Thompson. Reported by James Coleman.)

Features:

  • Add TLS server. (Reviewed by Stephen Frost, Reid Thompson, Andrew L’Ecuyer.)
  • Add --cmd option. (Contributed by Reid Thompson. Reviewed by Stefan Fercot, David Steele. Suggested by Virgile CREVON.)

Improvements:

  • Check archive immediately after backup start. (Reviewed by Reid Thompson, David Christensen.)
  • Add timeline and checkpoint checks to backup. (Reviewed by Stefan Fercot, Reid Thompson.)
  • Check that clusters are alive and correctly configured during a backup. (Reviewed by Stefan Fercot.)
  • Error when restore is unable to find a backup to match the time target. (Reviewed by Reid Thompson, Douglas J Hunley. Suggested by Douglas J Hunley.)
  • Parse protocol/port in S3/Azure endpoints. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Add warning when checkpoint_timeout exceeds db-timeout. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Add verb to HTTP error output. (Contributed by Christoph Berg. Reviewed by David Steele.)
  • Allow y/n arguments for boolean command-line options. (Contributed by Reid Thompson. Reviewed by David Steele.)
  • Make backup size logging exactly match info command output. (Contributed by Reid Thompson. Reviewed by David Steele. Suggested by Mahomed Hussein.)

Documentation Improvements:

  • Display size option default and allowed values with appropriate units. (Reviewed by Reid Thompson.)
  • Fix typos and improve documentation for the tablespace-map-all option. (Reviewed by Reid Thompson. Suggested by Reid Thompson.)
  • Remove obsolete statement about future multi-repository support. (Suggested by David Christensen.)

v2.36 Release Notes

Minor Bug Fixes and Improvements

Released November 1, 2021

Bug Fixes:

  • Allow “global” as a stanza prefix. (Reviewed by Stefan Fercot. Reported by Younes Alhroub.)
  • Fix segfault on invalid GCS key file. (Reviewed by Stephen Frost. Reported by Henrik Feldt.)

Improvements:

  • Allow link-map option to create new links. (Reviewed by Don Seiler, Stefan Fercot, Chris Bandy. Suggested by Don Seiler.)
  • Increase max index allowed for pg/repo options to 256. (Reviewed by Cynthia Shang.)
  • Add WebIdentity authentication for AWS S3. (Reviewed by James Callahan, Reid Thompson, Benjamin Blattberg, Andrew L’Ecuyer.)
  • Report backup file validation errors in backup.info. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Add recovery start time to online backup restore log. (Reviewed by Tom Swartz, Stefan Fercot. Suggested by Tom Swartz.)
  • Report original error and retries on local job failure. (Reviewed by Stefan Fercot.)
  • Rename page checksum error to error list in info text output. (Reviewed by Stefan Fercot.)
  • Add hints to standby replay timeout message. (Reviewed by Cynthia Shang, Stefan Fercot. Suggested by Leigh Downs.)

v2.35 Release Notes

Binary Protocol

Released August 23, 2021

IMPORTANT NOTE: This release moved copied-file messages for backup/restore to the detail log level. This reduces output at info level. To keep those messages, set the command log level to detail.

Bug Fixes:

  • Detect errors in S3 multi-part upload finalize. (Reviewed by Cynthia Shang, Marco Montagna. Reported by Marco Montagna, Lev Kokotov, Anderson A. Mallmann.)
  • Fix detection of circular symlinks. (Reviewed by Stefan Fercot. Reported by Rohit Raveendran.)
  • Only pass selected repo options to the remote. (Reviewed by David Christensen, Cynthia Shang. Reported by Greg Sabino Mullane, David Christensen.)

Improvements:

  • Binary protocol. (Reviewed by Cynthia Shang.)
  • Automatically create data directory on restore. (Contributed by Stefan Fercot. Reviewed by David Steele. Suggested by Chris Bandy.)
  • Allow restore --type=lsn. (Contributed by Stefan Fercot. Reviewed by Cynthia Shang. Suggested by James Coleman.)
  • Change level of backup/restore copied file logging to detail. (Reviewed by Stefan Fercot. Suggested by Jens Wilke.)
  • Loop while waiting for checkpoint LSN to reach replay LSN. (Contributed by Stefan Fercot. Reviewed by David Steele. Suggested by Fatih Mencutekin.)
  • Log backup file total and restore size/file total. (Reviewed by Cynthia Shang.)

Documentation Bug Fixes:

  • Fix incorrect host names in user guide. (Reviewed by Stefan Fercot. Reported by Greg Sabino Mullane.)

Documentation Improvements:

  • Update contributing documentation and add pull request template. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Rearrange backup documentation in user guide. (Reviewed by Cynthia Shang.)
  • Clarify restore --type behavior in command reference. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Fix documentation and comment typos. (Contributed by Eric Radman. Reviewed by David Steele.)

Test Suite Improvements:

  • Add check for test path inside repo path. (Reviewed by Greg Sabino Mullane. Suggested by Greg Sabino Mullane.)
  • Add CodeQL static code analysis. (Reviewed by Cynthia Shang.)
  • Update tests to use standard patterns. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v2.34 Release Notes

PostgreSQL 14 Support

Released June 7, 2021

Bug Fixes:

  • Fix issues with leftover spool files from a prior restore. (Reviewed by Cynthia Shang, Stefan Fercot, Floris van Nee. Reported by Floris van Nee.)
  • Fix issue when checking links for large numbers of tablespaces. (Reviewed by Cynthia Shang, Avinash Vallarapu. Reported by Avinash Vallarapu.)
  • Free no longer needed remotes so they do not timeout during restore. (Reviewed by Cynthia Shang. Reported by Francisco Miguel Biete Banon.)
  • Fix help when a valid option is invalid for the specified command. (Reviewed by Stefan Fercot. Reported by Cynthia Shang.)

Features:

  • Add PostgreSQL 14 support. (Reviewed by Cynthia Shang.)
  • Add automatic GCS authentication for GCE instances. (Reviewed by Jan Wieck, Daniel Farina.)
  • Add repo-retention-history option to expire backup history. (Contributed by Stefan Fercot. Reviewed by Cynthia Shang, David Steele.)
  • Add db-exclude option. (Contributed by Stefan Fercot. Reviewed by Cynthia Shang.)

Improvements:

  • Change archive expiration logging from detail to info level. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Remove stanza archive spool path on restore. (Reviewed by Cynthia Shang, Stefan Fercot.)
  • Do not write files atomically or sync paths during backup copy. (Reviewed by Stephen Frost, Stefan Fercot, Cynthia Shang.)

Documentation Improvements:

  • Update contributing documentation. (Contributed by Cynthia Shang. Reviewed by David Steele, Stefan Fercot.)
  • Consolidate RHEL/CentOS user guide into a single document. (Reviewed by Cynthia Shang.)
  • Clarify that repo-s3-role is not an ARN. (Contributed by Isaac Yuen. Reviewed by David Steele.)

v2.33 Release Notes

Multi-Repository and GCS Support

Released April 5, 2021

Bug Fixes:

  • Fix option warnings breaking async archive-get/archive-push. (Reviewed by Cynthia Shang. Reported by Lev Kokotov.)
  • Fix memory leak in backup during archive copy. (Reviewed by Cynthia Shang. Reported by Christian ROUX, Efremov Egor.)
  • Fix stack overflow in cipher passphrase generation. (Reviewed by Cynthia Shang. Reported by bsiara.)
  • Fix repo-ls / on S3 repositories. (Reviewed by Cynthia Shang. Reported by Lesovsky Alexey.)

Features:

  • Multiple repository support. (Contributed by Cynthia Shang, David Steele. Reviewed by Stefan Fercot, Stephen Frost.)
  • GCS support for repository storage. (Reviewed by Cynthia Shang, Daniel Farina.)
  • Add archive-header-check option. (Reviewed by Stephen Frost, Cynthia Shang. Suggested by Hans-Jürgen Schönig.)

Improvements:

  • Include recreated system databases during selective restore. (Contributed by Stefan Fercot. Reviewed by Cynthia Shang.)
  • Exclude content-length from S3 signed headers. (Reviewed by Cynthia Shang. Suggested by Brian P Bockelman.)
  • Consolidate less commonly used repository storage options. (Reviewed by Cynthia Shang.)
  • Allow custom config-path default with ./configure --with-configdir. (Contributed by Michael Schout. Reviewed by David Steele.)
  • Log archive copy during backup. (Reviewed by Cynthia Shang, Stefan Fercot.)

Documentation Improvements:

  • Update reference to include links to user guide examples. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Update selective restore documentation with caveats. (Reviewed by Cynthia Shang, Stefan Fercot.)
  • Add compress-type clarification to archive-copy documentation. (Reviewed by Cynthia Shang, Stefan Fercot.)
  • Add compress-level defaults per compress-type value. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Add note about required NFS settings being the same as PostgreSQL. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v2.32 Release Notes

Repository Commands

Released February 8, 2021

Bug Fixes:

  • Fix resume after partial delete of backup by prior resume. (Reviewed by Cynthia Shang. Reported by Tom Swartz.)

Features:

  • Add repo-ls command. (Reviewed by Cynthia Shang, Stefan Fercot.)
  • Add repo-get command. (Contributed by Stefan Fercot, David Steele. Reviewed by Cynthia Shang.)
  • Add archive-mode-check option. (Contributed by Stefan Fercot. Reviewed by David Steele, Michael Banck.)

Improvements:

  • Improve archive-get performance. (Reviewed by Cynthia Shang.)

Documentation Improvements:

  • Improve expire command documentation. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v2.31 Release Notes

Minor Bug Fixes and Improvements

Released December 7, 2020

Bug Fixes:

  • Allow [, #, and space as the first character in database names. (Reviewed by Stefan Fercot, Cynthia Shang. Reported by Jefferson Alexandre.)
  • Create standby.signal only on PostgreSQL 12 when restore type is standby. (Fixed by Stefan Fercot. Reviewed by David Steele. Reported by Keith Fiske.)

Features:

  • Expire history files. (Contributed by Stefan Fercot. Reviewed by David Steele.)
  • Report page checksum errors in info command text output. (Contributed by Stefan Fercot. Reviewed by Cynthia Shang.)
  • Add repo-azure-endpoint option. (Reviewed by Cynthia Shang, Brian Peterson. Suggested by Brian Peterson.)
  • Add pg-database option. (Reviewed by Cynthia Shang.)

Improvements:

  • Improve info command output when a stanza is specified but missing. (Contributed by Stefan Fercot. Reviewed by Cynthia Shang, David Steele. Suggested by uspen.)
  • Improve performance of large file lists in backup/restore commands. (Reviewed by Cynthia Shang, Oscar.)
  • Add retries to PostgreSQL sleep when starting a backup. (Reviewed by Cynthia Shang. Suggested by Vitaliy Kukharik.)

Documentation Improvements:

  • Replace RHEL/CentOS 6 documentation with RHEL/CentOS 8.

v2.30 Release Notes

PostgreSQL 13 Support

Released October 5, 2020

Bug Fixes:

  • Error with hints when backup user cannot read pg_settings. (Reviewed by Stefan Fercot, Cynthia Shang. Reported by Mohamed Insaf K.)

Features:

  • PostgreSQL 13 support. (Reviewed by Cynthia Shang.)

Improvements:

  • Improve PostgreSQL version identification. (Reviewed by Cynthia Shang, Stephen Frost.)
  • Improve working directory error message. (Reviewed by Stefan Fercot.)
  • Add hint about starting the stanza when WAL segment not found. (Contributed by David Christensen. Reviewed by David Steele.)
  • Add hint for protocol version mismatch. (Reviewed by Cynthia Shang. Suggested by loop-evgeny.)

Documentation Improvements:

  • Add note that pgBackRest versions must match when running remotely. (Reviewed by Cynthia Shang. Suggested by loop-evgeny.)
  • Move info command text to the reference and link to user guide. (Reviewed by Cynthia Shang. Suggested by Christophe Courtois.)
  • Update yum repository path for CentOS/RHEL user guide. (Contributed by Heath Lord. Reviewed by David Steele.)

v2.29 Release Notes

Auto S3 Credentials on AWS

Released August 31, 2020

Bug Fixes:

  • Suppress errors when closing local/remote processes. The command has already completed. Report a warn message to identify the unexpected condition without reporting a command error. (Reviewed by Cynthia Shang. Reported by argdenis.)
  • Fix issue with = character in file or database names. (Reviewed by Bastian Wegge, Cynthia Shang. Reported by Brad Nicholson, Bastian Wegge.)

Features:

  • Automatically retrieve temporary S3 credentials on AWS instances. (Contributed by David Steele, Stephen Frost. Reviewed by Cynthia Shang, David Youatt, Aleš Zelený, Jeanette Bromage.)
  • Add archive-mode option to disable archiving on restore. (Reviewed by Stephen Frost. Suggested by Stephen Frost.)

Improvements:

  • PostgreSQL 13 beta3 support. Later beta changes to control/catalog/WAL versions could break compatibility. pgBackRest updates were planned for each release.
  • Asynchronous list/remove for S3/Azure storage. (Reviewed by Cynthia Shang, Stephen Frost.)
  • Improve memory usage of unlogged relation detection in manifest build. (Reviewed by Cynthia Shang, Stephen Frost, Brad Nicholson, Oscar. Suggested by Oscar, Brad Nicholson.)
  • Proactively close file descriptors after forking async process. (Reviewed by Stephen Frost, Cynthia Shang.)
  • Delay backup remote connection close until after archive check. (Contributed by Floris van Nee. Reviewed by David Steele.)
  • Improve detailed error output. (Reviewed by Cynthia Shang.)
  • Improve TLS error reporting. (Reviewed by Cynthia Shang, Stephen Frost.)

Documentation Bug Fixes:

  • Add none to compress-type option reference and fix example. (Reported by Ugo Bellavance, Don Seiler.)
  • Add missing azure type in repo-type option reference. (Fixed by Don Seiler. Reviewed by David Steele.)
  • Fix typo in repo-cipher-type option reference. (Fixed by Don Seiler. Reviewed by David Steele.)

Documentation Improvements:

  • Clarify that expire must be run regularly when expire-auto is disabled. (Reviewed by Douglas J Hunley. Suggested by Douglas J Hunley.)

v2.28 Release Notes

Azure Repository Storage

Released July 20, 2020

Bug Fixes:

  • Fix restore --force acting like --force --delta. The affected restore used timestamp and size comparisons instead of overwriting files. It left some files unchanged that needed updates. Normal restore and restore --delta were unaffected. (Reviewed by Cynthia Shang.)

Features:

  • Azure support for repository storage. (Reviewed by Cynthia Shang, Don Seiler.)
  • Add expire-auto option. This allows automatic expiration after a successful backup to be disabled. (Contributed by Stefan Fercot. Reviewed by Cynthia Shang, David Steele.)

Improvements:

  • Asynchronous S3 multipart upload. (Reviewed by Stephen Frost.)
  • Automatic retry for backup, restore, archive-get, and archive-push. (Reviewed by Cynthia Shang.)
  • Disable query parallelism in PostgreSQL sessions used for backup control. (Reviewed by Stefan Fercot.)
  • PostgreSQL 13 beta2 support. Later beta changes to control/catalog/WAL versions could break compatibility. pgBackRest updates were planned for each release.
  • Improve handling of invalid HTTP response status. (Reviewed by Cynthia Shang.)
  • Improve error when pg1-path option missing for archive-get command. (Reviewed by Cynthia Shang.)
  • Add hint when checksum delta is enabled after a timeline switch. (Reviewed by Matt Bunter, Cynthia Shang.)
  • Use PostgreSQL instead of postmaster where appropriate. (Reviewed by Cynthia Shang.)

Documentation Bug Fixes:

  • Fix incorrect example for repo-retention-full-type option. (Reported by Höseyin Sönmez.)
  • Remove internal commands from HTML and man command references. (Reported by Cynthia Shang.)

Documentation Improvements:

  • Update PostgreSQL versions used to build user guides. Add version ranges to show which PostgreSQL versions a guide covers, even when examples use one specific version. (Reviewed by Stephen Frost.)
  • Update FAQ for expiring a specific backup set. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Update FAQ to clarify default PITR behavior. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v2.27 Release Notes

Expiration Improvements and Compression Drivers

Released May 26, 2020

Bug Fixes:

  • Fix issue checking if file links are contained in path links. (Reviewed by Cynthia Shang. Reported by Christophe Cavallié.)
  • Allow pg-path1 to be optional for synchronous archive-push. (Reviewed by Cynthia Shang. Reported by Jerome Peng.)
  • The expire command now checks if a stop file is present. (Fixed by Cynthia Shang. Reviewed by David Steele.)
  • Handle missing reason phrase in HTTP response. (Reviewed by Cynthia Shang. Reported by Tenuun.)
  • Increase buffer size for lz4 compression flush. (Reviewed by Cynthia Shang. Reported by Eric Radman.)
  • Ignore pg-host* and repo-host* options for the remote command. (Reviewed by Cynthia Shang. Reported by Pavel Suderevsky.)
  • Fix possibly missing pg1-* options for the remote command. (Reviewed by Cynthia Shang. Reported by Andrew L’Ecuyer.)

Features:

  • Time-based retention for full backups. The --repo-retention-full-type option allows retention of full backups based on a time period, specified in days. (Contributed by Cynthia Shang, Pierre Ducroquet. Reviewed by David Steele.)
  • Ad hoc backup expiration. Allow the user to remove a specified backup regardless of retention settings. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Zstandard compression support. Note that setting compress-type=zst will make new backups and archive incompatible (unrestorable) with prior versions of pgBackRest. (Reviewed by Cynthia Shang.)
  • bzip2 compression support. Note that setting compress-type=bz2 will make new backups and archive incompatible (unrestorable) with prior versions of pgBackRest. (Contributed by Stephen Frost. Reviewed by David Steele, Cynthia Shang.)
  • Add backup/expire running status to the info command. (Contributed by Stefan Fercot. Reviewed by David Steele.)

Improvements:

  • Expire WAL archive only when repo-retention-archive threshold is met. WAL prior to the first full backup was previously expired after the first full backup. Now it is preserved according to retention settings. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Add local MD5 implementation so S3 works when FIPS is enabled. (Reviewed by Cynthia Shang, Stephen Frost. Suggested by Brian Almeida, John Kelly.)
  • PostgreSQL 13 beta1 support. Later beta changes to control/catalog/WAL versions could break compatibility. pgBackRest updates were planned for each release. (Reviewed by Cynthia Shang.)
  • Reduce buffer-size default to 1MiB. (Reviewed by Stephen Frost.)
  • Throw user-friendly error if expire is not run on repository host. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v2.26 Release Notes

Non-blocking TLS

Released April 20, 2020

Bug Fixes:

  • Remove empty subexpression from manifest regular expression. This subexpression caused problems on macOS. Other platforms appeared unaffected. (Fixed by David Raftis. Reviewed by David Steele.)

Improvements:

  • Non-blocking TLS implementation. (Reviewed by Slava Moudry, Cynthia Shang, Stephen Frost.)
  • Only limit backup copy size for WAL-logged files. The prior behavior could possibly lead to postgresql.conf or postgresql.auto.conf being truncated in the backup. (Reviewed by Cynthia Shang.)
  • TCP keep-alive options are configurable. (Suggested by Marc Cousin.)
  • Add io-timeout option. (Reviewed by Cynthia Shang.)

v2.25 Release Notes

LZ4 Compression Support

Released March 26, 2020

Features:

  • Add lz4 compression support. Note that setting compress-type=lz4 will make new backups and archive incompatible (unrestorable) with prior versions of pgBackRest. (Reviewed by Cynthia Shang.)
  • Add --dry-run option to the expire command. Use dry-run to see which backups/archive would be removed by the expire command without actually removing anything. (Contributed by Cynthia Shang, Luca Ferrari. Reviewed by David Steele. Suggested by Marc Cousin.)

Improvements:

  • Improve performance of remote manifest build. (Suggested by Jens Wilke.)
  • Fix detection of keepalive options on Linux. (Contributed by Marc Cousin. Reviewed by David Steele.)
  • Add configure host detection to set standards flags correctly. (Contributed by Marc Cousin. Reviewed by David Steele.)
  • Remove compress/compress-level options from commands where unused. Commands such as restore and archive-get previously accepted these options without using them. This release reports an error when they are supplied. Remove the unused options if this error occurs. (Reviewed by Cynthia Shang.)
  • Limit backup file copy size to size reported at backup start. If a file grows during backup, WAL replay reconstructs the additional data during recovery. The backup does not need to copy it. (Reviewed by Cynthia Shang.)

v2.24 Release Notes

Auto-Select Backup Set for Time Target

Released February 25, 2020

Bug Fixes:

  • Prevent defunct processes in asynchronous archive commands. (Reviewed by Stephen Frost. Reported by Adam Brusselback, ejberdecia.)
  • Error when archive-get/archive-push/restore are not run on a PostgreSQL host. (Reviewed by Stephen Frost. Reported by Jesper St John.)
  • Read HTTP content to eof when size/encoding not specified. (Reviewed by Cynthia Shang. Reported by Christian ROUX.)
  • Fix resume when the resumable backup was created by Perl. The backup should be ignored in this case. However, C code could not load the partial Perl manifest because the formats differed slightly. Add checks to detect this case and continue. (Reported by Kacey Holston.)

Features:

  • Auto-select backup set on restore when time target is specified. Select automatically only when --set is absent. If no backup set matches the target time, use the latest backup set, which is the default. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Improvements:

  • Skip pg_internal.init temp file during backup. (Reviewed by Cynthia Shang. Suggested by Michael Paquier.)
  • Add more validations to the manifest on backup. (Reviewed by Cynthia Shang.)

Documentation Improvements:

  • Prevent lock-bot from adding comments to locked issues. (Suggested by Christoph Berg.)

v2.23 Release Notes

Bug Fix

Released January 27, 2020

Bug Fixes:

  • Fix missing files corrupting the manifest. If PostgreSQL removed a file during backup, the next file might not be copied or updated in the manifest. A file missing from the standby could cause the same problem. Restoring such a backup produced an error. (Reviewed by Cynthia Shang. Reported by Vitaliy Kukharik.)

Improvements:

  • Use pkg-config instead of xml2-config for libxml2 build options. (Contributed by David Steele, Adrian Vondendriesch.)
  • Validate checksums are set in the manifest on backup/restore. (Reviewed by Cynthia Shang.)

v2.22 Release Notes

Bug Fix

Released January 21, 2020

Bug Fixes:

  • Fix error in timeline conversion. The timeline is required to verify WAL segments in the archive after a backup. Conversion used base 10 instead of 16. This caused errors for timelines ≥ 0xA. (Reported by Lukas Ertl, Eric Veldhuyzen.)

v2.21 Release Notes

C Migration Complete

Released January 15, 2020

Bug Fixes:

  • Fix options being ignored by asynchronous commands. The asynchronous archive-get/archive-push processes were not loading options configured in command configuration sections, e.g. [global:archive-get]. (Reviewed by Cynthia Shang. Reported by Urs Kramer.)
  • Fix handling of \ in filenames. Manifest checksum calculation escaped \ incorrectly, which prevented manifest loading. Cluster filenames rarely contain \, so a serious production problem was unlikely.

Features:

  • pgBackRest is now pure C.
  • Add pg-user option. Specifies the database user name when connecting to PostgreSQL. If not specified pgBackRest will connect with the local OS user or PGUSER, which was the previous behavior. (Contributed by Mike Palmiotto. Reviewed by David Steele.)
  • Allow path-style URIs in S3 driver.

Improvements:

  • The backup command is implemented entirely in C. (Reviewed by Cynthia Shang.)

v2.20 Release Notes

Bug Fixes

Released December 12, 2019

Bug Fixes:

  • Fix archive-push/archive-get when PGDATA is symlinked. These commands used cwd() as PGDATA. For a symlinked PGDATA, it differed from the configured pgBackRest path. If the paths differ, call chdir() with the configured path. Then verify that cwd() matches its first result. (Reported by Stephen Frost, Milosz Suchy.)
  • Fix reference list when backup.info is reconstructed in expire command. At this release, backup still used the Perl reconstruction code. The issue required both conditions: 1) a backup was missing from backup.info; 2) expire ran directly instead of automatically after backup. This combination was unlikely in production.
  • Fix segfault on unexpected EOF in gzip decompression. (Reported by Stephen Frost.)

v2.19 Release Notes

C Migrations and Bug Fixes

Released November 12, 2019

Bug Fixes:

  • Fix remote timeout in delta restore. During a delta restore of a mostly unchanged cluster, the remote could time out. This occurred if no repository files were fetched within protocol-timeout. Add keep-alives to prevent this timeout. (Reported by James Sewell, Jens Wilke.)
  • Fix handling of repeated HTTP headers. Treat repeated HTTP headers as one comma-separated header. Earlier versions reported an error. (Reported by donicrosby.)

Improvements:

  • JSON output from the info command is no longer pretty-printed. JSON without linefeeds is easier for monitoring systems to ingest. For formatted output, use an external tool such as jq. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • The check command is implemented entirely in C. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Documentation Improvements:

  • Document how to contribute to pgBackRest. (Contributed by Cynthia Shang, David Steele.)
  • Document maximum version for auto-stop option. (Contributed by Brad Nicholson. Reviewed by David Steele.)

Test Suite Improvements:

  • Fix container test path being used when --vm=none. (Suggested by Stephen Frost.)
  • Fix mismatched timezone in expect test. (Suggested by Stephen Frost.)
  • Don’t autogenerate embedded libc code by default. (Suggested by Stephen Frost.)

v2.18 Release Notes

PostgreSQL 12 Support

Released October 1, 2019

Features:

  • PostgreSQL 12 support.
  • Add info command set option for detailed text output. Details include databases available for selective restore. They also list tablespaces and symlinks with their default destinations. (Contributed by Cynthia Shang. Reviewed by David Steele. Suggested by Stephen Frost, ejberdecia.)
  • Add standby restore type. For PostgreSQL < 12, this type adds standby_mode=on to recovery.conf. For PostgreSQL ≥ 12, it creates standby.signal. This provides one interface across PostgreSQL versions. (Reviewed by Cynthia Shang.)

Improvements:

  • The restore command is implemented entirely in C. (Reviewed by Cynthia Shang.)

Documentation Improvements:

  • Document the relationship between db-timeout and protocol-timeout. (Contributed by Cynthia Shang. Reviewed by David Steele. Suggested by James Chanco Jr.)
  • Add documentation clarifications regarding standby repositories. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Add FAQ for time-based Point-in-Time Recovery. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v2.17 Release Notes

C Migrations and Bug Fixes

Released September 3, 2019

Bug Fixes:

  • Improve slow manifest build for very large quantities of tables/segments. (Reported by Jens Wilke.)
  • Fix exclusions for special files. (Reported by CluelessTechnologist, Janis Puris, Rachid Broum.)

Improvements:

  • The stanza-create/update/delete commands are implemented entirely in C. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • The start/stop commands are implemented entirely in C. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Create log directories/files with 0750/0640 mode. (Suggested by Damiano Albani.)

Documentation Bug Fixes:

  • Fix yum.p.o package being installed when custom package specified. (Reported by Joe Ayers, John Harvey.)

Documentation Improvements:

  • Build pgBackRest as an unprivileged user. (Suggested by Laurenz Albe.)

v2.16 Release Notes

C Migrations and Bug Fixes

Released August 5, 2019

Bug Fixes:

  • Retry S3 RequestTimeTooSkewed errors instead of immediately terminating. (Reported by sean0101n, Tim Garton, Jesper St John, Aleš Zelený.)
  • Fix incorrect handling of transfer-encoding response to HEAD request. (Reported by Pavel Suderevsky.)
  • Fix scoping violations exposed by optimizations in gcc 9. (Reported by Christian Lange, Ned T. Crigler.)

Features:

  • Add repo-s3-port option for setting a non-standard S3 service port.

Improvements:

  • The local command for backup is implemented entirely in C. (Contributed by David Steele, Cynthia Shang.)
  • The check command is implemented partly in C. (Reviewed by Cynthia Shang.)

v2.15 Release Notes

C Implementation of Expire

Released June 25, 2019

Bug Fixes:

  • Fix archive retention expiring too aggressively. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Mohamad El-Rifai.)

Improvements:

  • The expire command is implemented entirely in C. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • The local command for restore is implemented entirely in C.
  • Remove hard-coded PostgreSQL user so $PGUSER works. (Suggested by Julian Zhang, Janis Puris.)
  • Honor configure --prefix option. (Suggested by Daniel Westermann.)
  • Rename repo-s3-verify-ssl option to repo-s3-verify-tls. Prefer the new name because pgBackRest supports no SSL protocol versions; all are considered insecure. The old name remains accepted.

Documentation Improvements:

  • Add FAQ to the documentation. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Use wal_level=replica in the documentation for PostgreSQL ≥ 9.6. (Suggested by Patrick McLaughlin.)

v2.14 Release Notes

Bug Fix and Improvements

Released May 20, 2019

Bug Fixes:

  • Fix segfault when process-max > 8 for archive-push/archive-get. (Reported by Jens Wilke.)

Improvements:

  • Bypass database checks when stanza-delete issued with force. (Contributed by Cynthia Shang. Reviewed by David Steele. Suggested by hatifnatt.)
  • Add configure script for improved multi-platform support.

Documentation Features:

  • Add user guides for CentOS/RHEL 6/7.

v2.13 Release Notes

Bug Fixes

Released April 18, 2019

Bug Fixes:

  • Fix zero-length reads causing problems for IO filters that did not expect them. (Reported by brunre01, Jens Wilke, Tomasz Kontusz, guruguruguru.)
  • Fix reliability of error reporting from local/remote processes.
  • Fix Posix/CIFS error messages reporting the wrong filename on write/sync/close.

v2.12 Release Notes

C Implementation of Archive Push

Released April 11, 2019

IMPORTANT NOTE: The new TLS/SSL implementation forbids dots in S3 bucket names per RFC-2818. This security fix is required for compliant hostname verification.

Bug Fixes:

  • Fix issues when a path option is / terminated. (Reported by Marc Cousin.)
  • Fix issues when log-level-file=off is set for the archive-get command. (Reported by Brad Nicholson.)
  • Fix C code to recognize host:port option format like Perl does. (Reported by Kyle Nevins.)
  • Fix issues with remote/local command logging options.

Improvements:

  • The archive-push command is implemented entirely in C.
  • Increase process-max limit to 999. (Suggested by Rakshitha-BR.)
  • Improve error message when an S3 bucket name contains dots.

Documentation Improvements:

  • Clarify that S3-compatible object stores are supported. (Suggested by Magnus Hagander.)

v2.11 Release Notes

C Implementation of Archive Get

Released March 11, 2019

Bug Fixes:

  • Fix possible truncated WAL segments when an error occurs mid-write. (Reported by blogh.)
  • Fix info command missing WAL min/max when stanza specified. (Fixed by Stefan Fercot. Reviewed by David Steele.)
  • Fix non-compliant JSON for options passed from C to Perl. (Reported by Leo Khomenko.)

Improvements:

  • The archive-get command is implemented entirely in C.
  • Enable socket keep-alive on older Perl versions. (Contributed by Marc Cousin. Reviewed by David Steele.)
  • Error when parameters are passed to a command that does not accept parameters. (Suggested by Jason O’Donnell.)
  • Add hints when unable to find a WAL segment in the archive. (Suggested by Hans-Jürgen Schönig.)
  • Improve error when hostname cannot be found in a certificate. (Suggested by James Badger.)
  • Add additional options to backup.manifest for debugging purposes. (Contributed by blogh. Reviewed by David Steele.)

Documentation Improvements:

  • Update default documentation version to PostgreSQL 10.

v2.10 Release Notes

Bug Fixes

Released February 9, 2019

Bug Fixes:

  • Add unimplemented S3 driver method required for archive-get. (Reported by mibiio.)
  • Fix check for improperly configured pg-path. (Reported by James Chanco Jr.)

v2.09 Release Notes

Minor Improvements and Bug Fixes

Released January 30, 2019

Bug Fixes:

  • Fix issue with multiple async status files causing a hard error. (Reported by Vidhya Gurumoorthi, Joe Ayers, Douglas J Hunley.)

Improvements:

  • The info command is implemented entirely in C. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Simplify info command text message when no stanzas are present. Replace the repository path with “the repository”.
  • Add _DARWIN_C_SOURCE flag to Makefile for MacOS builds. (Contributed by Douglas J Hunley. Reviewed by David Steele.)
  • Update address lookup in C TLS client to use modern methods. (Suggested by Bruno Friedmann.)
  • Include Posix-compliant header for strcasecmp() and fd_set. (Suggested by ucando.)

Documentation Bug Fixes:

  • Fix hard-coded repository path. (Reported by Heath Lord.)

Documentation Improvements:

  • Clarify that encryption is always performed client-side. (Suggested by Bruce Burdick.)
  • Add examples for building a documentation host.
  • Allow if in manifest variables, lists, and list items.

v2.08 Release Notes

Minor Improvements and Bug Fixes

Released January 2, 2019

Bug Fixes:

  • Remove request for S3 object info directly after putting it. (Reported by Matt Kunkel.)
  • Correct archive-get-queue-max to be size type. (Reported by Ronan Dunklau.)
  • Add error message when current user uid/gid does not map to a name. (Reported by Camilo Aguilar.)
  • Error when --target-action=shutdown specified for PostgreSQL < 9.5.

Improvements:

  • Set TCP keepalives on S3 connections. (Suggested by Ronan Dunklau.)
  • Reorder info command text output so most recent backup is output last. (Contributed by Cynthia Shang. Reviewed by David Steele. Suggested by Ryan Lambert.)
  • Change file ownership only when required.
  • Redact authentication header when throwing S3 errors. (Suggested by Brad Nicholson.)

Documentation Improvements:

  • Clarify when target-action is effective and PostgreSQL version support. (Suggested by Keith Fiske.)
  • Clarify that region/endpoint must be configured correctly for the bucket. (Suggested by Pritam Barhate.)
  • Add documentation for building the documentation.

v2.07 Release Notes

Automatic Backup Checksum Delta

Released November 16, 2018

Bug Fixes:

  • Fix issue with archive-push-queue-max not being honored on connection error. (Reported by Lardière Sébastien.)
  • Fix static WAL segment size used to determine if archive-push-queue-max has been exceeded.
  • Fix error after log file open failure when processing should continue. (Reported by vthriller.)

Features:

  • Automatically enable backup checksum delta when anomalies (e.g. timeline switch) are detected. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Improvements:

  • Retry all S3 5xx errors rather than just 500 internal errors. (Suggested by Craig A. James.)

v2.06 Release Notes

Checksum Delta Backup and PostgreSQL 11 Support

Released October 15, 2018

Bug Fixes:

  • Fix missing URI encoding in S3 driver. (Reported by Dan Farrell.)
  • Fix incorrect error message for duplicate options in configuration files. (Reported by Jesper St John.)
  • Fix incorrectly reported error return in info logging. The archive-get return code 1 was logged as an error at info level. Operation was otherwise correct.

Features:

  • Add checksum delta for incremental backups. Checksum delta backups uses checksums rather than timestamps to determine if files have changed. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • PostgreSQL 11 support, including configurable WAL segment size.

Improvements:

  • Ignore all files in a linked tablespace directory except the subdirectory for the current version of PostgreSQL. Previously, other files not owned by the PostgreSQL user caused an error.
  • Improve info command to display the stanza cipher type. (Contributed by Cynthia Shang. Reviewed by David Steele. Suggested by Douglas J Hunley.)
  • Improve support for special characters in filenames.
  • Allow delta option to be specified in the pgBackRest configuration file. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Documentation Improvements:

  • Use command in authorized_hosts to improve SSH security. (Suggested by Stephen Frost, Magnus Hagander.)
  • List allowable values for the buffer-size option in the configuration reference. (Contributed by Cynthia Shang. Reviewed by David Steele. Suggested by Stéphane Schildknecht.)

v2.05 Release Notes

Environment Variable Options and Exclude Temporary/Unlogged Relations

Released August 31, 2018

Bug Fixes:

  • Fix issue where relative links in $PGDATA could be stored in the backup with the wrong path. Absolute links were unaffected. Other checks detected relative tablespace links. (Reported by Cynthia Shang.)
  • Remove incompletely implemented online option from the check command. The command checks whether archiving and backups work correctly, which requires online operation. (Reported by Jason O’Donnell.)
  • Fix issue where errors raised in C were not logged when called from Perl. pgBackRest properly terminated with the correct error code but lacked an error message to aid in debugging. (Reported by Douglas J Hunley.)
  • Fix issue when a boolean option (e.g. delta) was specified more than once. (Reported by Yogesh Sharma.)

Features:

  • Allow any option to be set in an environment variable. This includes previously command-line-only options, such as stanza. It also includes secret options prohibited on the command line, such as repo1-s3-key-secret.
  • Exclude temporary and unlogged relation (table/index) files from backup. Implemented using the same logic as the patches adding this feature to PostgreSQL, 8694cc96 and 920a5e50. Temporary relation exclusion is enabled in PostgreSQL ≥ 9.0. Unlogged relation exclusion is enabled in PostgreSQL ≥ 9.1, where the feature was introduced. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Allow arbitrary directories and/or files to be excluded from a backup. Incorrect exclusions can make backups inconsistent. Read the --exclude documentation carefully before use. (Reviewed by Cynthia Shang.)
  • Add log-subprocess option to allow file logging for local and remote subprocesses.
  • PostgreSQL 11 Beta 3 support.

Improvements:

  • Allow zero-size files in backup manifest to reference a prior manifest regardless of timestamp delta. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Improve asynchronous archive-get/archive-push performance by directly checking status files. (Contributed by Stephen Frost. Reviewed by David Steele.)
  • Improve error message when a command is missing the stanza option. (Suggested by Sarah Conway.)

Documentation Bug Fixes:

  • Fix invalid log level in log-path option reference. (Reported by Camilo Aguilar.)

Documentation Improvements:

  • Stop trying to arrange contributors in release.xml by last/first name. Release notes always preserve contributor names as supplied. Internal IDs previously used inferred last/first names, which can be difficult to determine reliably. Inspired by Christophe’s PostgresOpen 2017 talk, “Human Beings Do Not Have a Primary Key”. (Suggested by Christophe Pettus.)

Test Suite Improvements:

  • Error if LibC build is performed outside the test environment. LibC is no longer required for production builds.

v2.04 Release Notes

Critical Bug Fix for Backup Resume

Released July 5, 2018

IMPORTANT NOTE: This release fixed a critical backup resume bug. Treat all resumed backups from earlier releases as inconsistent. After a failed backup, pgBackRest resumes unless resume=n is set. Check backup logs for the exact message “aborted backup of same type exists, will be cleaned to remove invalid files and resumed”. If present, do not restore that backup or any backup in the same set.

Check restore logs to see whether a resumed backup was restored. If so, the cluster might contain inconsistent data.

Bug Fixes:

  • Fix critical bug in resume that resulted in inconsistent backups. A regression in v0.82 removed the timestamp comparison when deciding which files from the aborted backup to keep on resume. See note above for more details. (Reported by David Youatt, Yogesh Sharma, Stephen Frost.)
  • Fix error in selective restore when only one user database exists in the cluster. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Nj Baliyan.)
  • Fix non-compliant ISO-8601 timestamp format in S3 authorization headers. AWS and some gateways accepted space-padded hours. Others required zero-padded hours. (Fixed by Andrew Schwartz. Reviewed by David Steele.)

Features:

  • PostgreSQL 11 Beta 2 support.

Improvements:

  • Improve the HTTP client to set content-length to 0 when not specified by the server. S3 and its gateways always set content-length or transfer-encoding. HTTP 1.1 does not require either header, and proxies such as HAProxy might omit both. (Suggested by Adam K. Sumner.)
  • Set search_path = 'pg_catalog' on PostgreSQL connections. (Suggested by Stephen Frost.)

Documentation Improvements:

  • Create a new section to describe building pgBackRest and build on a separate host.
  • Add sample S3 policy to restrict bucket privileges. (Suggested by Douglas J Hunley, Jason O’Donnell.)

v2.03 Release Notes

Single Executable to Deploy

Released May 22, 2018

Bug Fixes:

  • Fix potential buffer overrun in error message handling. (Reported by Lætitia.)
  • Fix archive write lock being taken for the synchronous archive-get command. (Reported by uspen.)

Improvements:

  • Embed exported C functions and Perl modules directly into the pgBackRest executable.
  • Use time_t instead of __time_t for better portability. (Suggested by Nick Floersch.)
  • Print total runtime in milliseconds at command end.

v2.02 Release Notes

Parallel Asynchronous Archive Get and Configuration Includes

Released May 6, 2018

Bug Fixes:

  • Fix directory syncs running recursively when only the specified directory should be synced. (Reported by Craig A. James.)
  • Fix archive-copy throwing “path not found” error for incr/diff backups. (Reported by yummyliu, Vitaliy Kukharik.)
  • Fix failure in manifest build when two or more files in PGDATA are linked to the same directory. (Reported by Vitaliy Kukharik.)
  • Fix delta restore failing when a linked file is missing.
  • Fix rendering of key/value and list options in help. (Reported by Clinton Adams.)

Features:

  • Add asynchronous, parallel archive-get. This feature maintains a queue of WAL segments to help reduce latency when PostgreSQL requests a WAL segment with restore_command.
  • Add support for additional pgBackRest configuration files. The directory is specified by the --config-include-path option. Add --config-path option for overriding the default base path of the --config and --config-include-path option. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Add repo-s3-token option to allow temporary credentials tokens to be configured. At this release, pgBackRest could not request new credentials. The complete command, such as backup or restore, had to finish before expiration. (Contributed by Yogesh Sharma. Reviewed by David Steele.)

Improvements:

  • Update the archive-push-queue-max, manifest-save-threshold, and buffer-size options to accept values in KB, MB, GB, TB, or PB where the multiplier is a power of 1024. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Make backup/restore path sync more efficient. Scanning directories with many small tables can be expensive. Use the path list in the backup manifest for syncs instead of scanning the backup/restore path.
  • Show command parameters as well as command options in initial info log message.
  • Rename archive-queue-max option to archive-push-queue-max. This is consistent with the new archive-get-queue-max option. The old option name will continue to be accepted.

Documentation Bug Fixes:

  • Update docs with 32-bit support and caveats. 32-bit support was added in v1.26. (Reported by Viorel Tabara.)

Documentation Improvements:

  • Add monitoring examples using PostgreSQL and jq. (Suggested by Stephen Frost, Brian Faherty.)
  • Add example of command section usage to archiving configuration. (Suggested by Christophe Courtois.)
  • Remove documentation describing info --output=json as experimental.
  • Update out-of-date description for the spool-path option.

Test Suite Features:

  • Use lcov for C unit test coverage reporting. Replace Devel::Cover, which omitted branch coverage from converted gcov reports. Incomplete module branch coverage now generates an error. The report shows unit-test coverage only when statement or branch coverage is incomplete.

v2.01 Release Notes

Minor Bug Fixes and Improvements

Released March 19, 2018

Bug Fixes:

  • Fix --target-action and --recovery-option options being reported as invalid when restoring with --type=immediate. (Reported by Brad Nicholson.)
  • Immediately error when a secure option (e.g. repo1-s3-key) is passed on the command line. pgBackRest did not pass secure options to subprocesses, which caused an unclear error. The new error explains the problem and provides correction hints. Remove secure options that cannot be supplied on the command line from command documentation. (Reported by Brad Nicholson.)
  • Fix issue passing --no-config to embedded Perl. (Reported by Ibrahim Edib Kokdemir.)
  • Fix exit errors in local/remote processes when log-level-stderr > warn. Unexpected stderr output caused these errors. Limit subprocess logging to error, because these processes do not need to report warnings. (Reported by Clinton Adams.)
  • Fix manifest test in the check command when tablespaces are present. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Thomas Flatley.)

Improvements:

  • Error when multiple arguments are set in the config file for an option that does not accept multiple arguments. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Remove extraneous sudo commands from src/Makefile. (Contributed by Adrian Vondendriesch. Reviewed by David Steele.)

Documentation Improvements:

  • Show index in examples for indexed options, i.e. repo-*, pg-*. (Suggested by Stephen Frost.)
  • Simplify table of contents on command page by only listing commands. (Suggested by Stephen Frost.)
  • Remove references to the C library being optional.

Test Suite Features:

  • Add CentOS/RHEL package builds.
  • Use clang for static code analysis. Nothing found initially except for some functions that should have been marked __noreturn__.

v2.00 Release Notes

Performance Improvements for Archive Push

Released February 23, 2018

Features:

  • Implement part of archive-push in C. This substantially speeds PostgreSQL archive_command processing of status messages from the asynchronous archive process. (Reviewed by Cynthia Shang.)

Improvements:

  • Improve check command to verify that the backup manifest can be built. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Improve performance of HTTPS client. Buffering now includes socket pending bytes, when present, instead of relying only on select(). Previously, final bytes sometimes remained unflushed until the connection closed.
  • Improve S3 delete performance. The constant S3_BATCH_MAX had been replaced with a hard-coded value of 2, probably during testing.
  • Allow any non-command-line option to be reset to default on the command-line. Reset options from pgbackrest.conf to their defaults without creating a separate configuration file for a specific operation.
  • The C library is now required. This eliminates conditional loading and eases development of new library features.
  • The pgbackrest executable is now a C binary instead of Perl. This allows certain time-critical commands (like async archive-push) to run more quickly.
  • Rename db-* options to pg-* and backup-* options to repo-* to improve consistency. repo-* options are now indexed although currently only one is allowed.

Documentation Features:

  • All clusters in the documentation are initialized with checksums.

Documentation Improvements:

  • List deprecated option names in documentation and command-line help.
  • Clarify that S3 buckets must be created by the user. (Suggested by David Youatt.)

v1.29 Release Notes

Critical Bug Fix for Backup Resume

Released July 5, 2018

IMPORTANT NOTE: This release fixed a critical backup resume bug. Treat all resumed backups from earlier releases as inconsistent. After a failed backup, pgBackRest resumes unless resume=n is set. Check backup logs for the exact message “aborted backup of same type exists, will be cleaned to remove invalid files and resumed”. If present, do not restore that backup or any backup in the same set.

Check restore logs to see whether a resumed backup was restored. If so, the cluster might contain inconsistent data.

Bug Fixes:

  • Fix critical bug in resume that resulted in inconsistent backups. A regression in v0.82 removed the timestamp comparison when deciding which files from the aborted backup to keep on resume. See note above for more details. (Reported by David Youatt, Yogesh Sharma, Stephen Frost.)
  • Fix non-compliant ISO-8601 timestamp format in S3 authorization headers. AWS and some gateways accepted space-padded hours. Others required zero-padded hours. (Fixed by Andrew Schwartz. Reviewed by David Steele.)
  • Fix directory syncs running recursively when only the specified directory should be synced. (Reported by Craig A. James.)
  • Fix --target-action and --recovery-option options being reported as invalid when restoring with --type=immediate. (Reported by Brad Nicholson.)
  • Fix archive-copy throwing “path not found” error for incr/diff backups. (Reported by yummyliu, Vitaliy Kukharik.)
  • Fix failure in manifest build when two or more files in PGDATA are linked to the same directory. (Reported by Vitaliy Kukharik.)
  • Fix delta restore failing when a linked file was missing.
  • Fix error in selective restore when only one user database exists in the cluster. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Nj Baliyan.)

Improvements:

  • Improve the HTTP client to set content-length to 0 when not specified by the server. S3 and its gateways always set content-length or transfer-encoding. HTTP 1.1 does not require either header, and proxies such as HAProxy might omit both. (Suggested by Adam K. Sumner.)
  • Improve performance of HTTPS client. Buffering now includes socket pending bytes, when present, instead of relying only on select(). Previously, final bytes sometimes remained unflushed until the connection closed.
  • Improve S3 delete performance. The constant S3_BATCH_MAX had been replaced with a hard-coded value of 2, probably during testing.
  • Make backup/restore path sync more efficient. Scanning directories with many small tables can be expensive. Use the path list in the backup manifest for syncs instead of scanning the backup/restore path. Remove recursive path sync functionality since it is no longer used.

Documentation Bug Fixes:

  • Update docs with 32-bit support and caveats. 32-bit support was added in v1.26. (Reported by Viorel Tabara.)

Documentation Improvements:

  • Clarify that S3 buckets must be created by the user. (Suggested by David Youatt.)
  • Update out-of-date description for the spool-path option.

v1.28 Release Notes

Stanza Delete

Released February 1, 2018

Bug Fixes:

  • Fixed inability to restore a single database contained in a tablespace using –db-include. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Chiranjeevi Ravilla.)
  • Ensure latest db-id is selected on when matching archive.info to backup.info. This handles duplicate system-id and db-version values, for example after reverting a pg_upgrade. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Adam K. Sumner.)
  • Fixed overly chatty error message when reporting an invalid command. (Reported by Jason O’Donnell.)

Features:

  • Add stanza-delete command to cleanup unused stanzas. (Contributed by Cynthia Shang. Reviewed by David Steele. Suggested by Magnus Hagander.)

Improvements:

  • Improve stanza-create command so that it does not error when the stanza already exists. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Documentation Improvements:

  • Update stanza-create --force documentation to urge caution when using. (Suggested by Jason O’Donnell.)

v1.27 Release Notes

Bug Fixes and Documentation

Released December 19, 2017

Bug Fixes:

  • Fixed an issue that suppressed locality errors for backup and restore. With a backup host configured, backups must run there and restores must run on the database host. An alternative configuration that ignores the remote host can override this restriction. (Reported by Lardière Sébastien.)
  • Fixed an issue where WAL was not expired on PostgreSQL 10. This was caused by a faulty regex that expected all PostgreSQL major versions to be X.X. (Reported by Adam Brusselback.)
  • Fixed an issue where the --no-config option was not passed to child processes. This meant the child processes would still read the local config file and possibly cause unexpected behaviors.
  • Fixed info command to eliminate "db (prior)" output if no backups or archives exist for a prior version of the cluster. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Stephen Frost.)

Documentation Features:

  • Document the relationship between the archive-copy and archive-check options. (Suggested by Markus Nullmeier.)
  • Improve archive-copy reference documentation.

v1.26 Release Notes

Repository Encryption

Released November 21, 2017

Bug Fixes:

  • Fixed an issue that could cause copying large manifests to fail during restore. (Reported by Craig A. James.)
  • Fixed incorrect WAL offset for 32-bit architectures. (Fixed by Javier Wilson. Reviewed by David Steele.)
  • Fixed an issue retrieving WAL for old database versions. After stanza-upgrade, backups from the previous version should still support restore and recovery with archive-get. However, archive-get checked only the latest db version/id and failed. Also fix repeated db version/id values in history. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Clinton Adams.)
  • Fixed an issue with invalid backup groups being set correctly on restore. When a group cannot be mapped to a name, the backup manifest stores false. Restore then uses the group from the owner of $PGDATA, or the current user’s group if unavailable. Previously, this logic assigned the selected group to the user field. It left the group undefined and set the user incorrectly. (Reported by Jeff McCormick.)
  • Fixed an issue passing parameters to remotes. With multiple databases configured, pgBackRest passed the db1 path, port, and socket path regardless of the selected database. (Reported by uspen.)

Features:

  • Repository encryption support. (Contributed by Cynthia Shang, David Steele.)

Improvements:

  • Disable gzip filter when --compress-level-network=0. The filter was used with compress level set to 0 which added overhead without any benefit.
  • Inflate performance improvement for gzip filter.

Documentation Features:

  • Add template to improve initial information gathered for issue submissions. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Documentation Improvements:

  • Clarify usage of the archive-timeout option and describe how it is distinct from the PostgreSQL archive_timeout setting. (Contributed by Cynthia Shang. Reviewed by David Steele. Suggested by Keith Fiske.)

Test Suite Features:

  • Automated tests for 32-bit i386/i686 architecture.

v1.25 Release Notes

S3 Performance Improvements

Released October 24, 2017

Bug Fixes:

  • Fix custom settings for compress-level option being ignored. (Reported by Jens Wilke.)
  • Remove error when overlapping timelines are detected. Overlapping timelines are valid in many Point-in-Time-Recovery (PITR) scenarios. (Reported by blogh.)
  • Fix instances where database-id was not rendered as an integer in JSON info output. (Fixed by Cynthia Shang. Reviewed by David Steele. Reported by Jason O’Donnell.)

Features:

  • Improve performance of list requests on S3. Use the initial literal part of a filter expression as the search prefix. This often reduces request size enough to avoid rate limiting. (Suggested by Mihail Shvein.)

Test Suite Features:

  • Add I/O performance tests.

v1.24 Release Notes

New Backup Exclusions

Released September 28, 2017

Bug Fixes:

  • Fixed an issue where warnings were being emitted in place of lower priority log messages during backup from standby initialization. (Reported by uspen.)
  • Fixed an issue where some db-* options (e.g. db-port) were not being passed to remotes. (Reported by uspen.)

Features:

  • Exclude contents of pg_snapshots, pg_serial, pg_notify, and pg_dynshmem from backup since they are rebuilt on startup.
  • Exclude pg_internal.init files from backup since they are rebuilt on startup.

Improvements:

  • Open the log file after the asynchronous process fully separates from the main process. This prevents the main process from writing to that file. (Suggested by Jens Wilke.)

Documentation Features:

  • Add passwordless SSH configuration.

Documentation Improvements:

  • Rename master to primary in documentation to align with PostgreSQL convention.

v1.23 Release Notes

Multiple Standbys and PostgreSQL 10 Support

Released September 3, 2017

Bug Fixes:

  • Fixed an issue that could cause compression to abort on growing files. (Reported by Jesper St John, Aleksandr Rogozin.)
  • Fixed an issue with keep-alives not being sent to the remote from the local process. (Reported by William Cox.)

Features:

  • Up to seven standbys can be configured for backup from standby. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • PostgreSQL 10 support.
  • Allow content-length (in addition to chunked encoding) when reading XML data to improve compatibility with third-party S3 gateways. (Suggested by Victor Gdalevich.)

Improvements:

  • Increase HTTP timeout for S3.
  • Add HTTP retries to harden against transient S3 network errors.

Documentation Bug Fixes:

  • Fixed document generation to include section summaries on the Configuration page. (Fixed by Cynthia Shang. Reviewed by David Steele.)

v1.22 Release Notes

Fixed S3 Retry

Released August 9, 2017

Bug Fixes:

  • Fixed authentication issue in S3 retry.

v1.21 Release Notes

Improved Info Output and SSH Port Option

Released August 8, 2017

Bug Fixes:

  • Recreate archive_status during restore for PostgreSQL 8.3. Later PostgreSQL versions recreate it automatically. (Reported by Stephen Frost.)
  • Fixed an issue that could cause the empty archive directory for an old PostgreSQL version to be left behind after a stanza-upgrade. (Fixed by Cynthia Shang. Reviewed by David Steele.)

Features:

  • Modify info text and JSON output to show the archive ID and minimum/maximum archived WAL. Include the current database cluster version and any previous versions. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Added --backup-ssh-port and --db-ssh-port options to support non-default SSH ports. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Improvements:

  • Retry when S3 returns an internal error (500).

Documentation Bug Fixes:

  • Fix description of --online based on the command context.

Documentation Features:

  • Add creation of /etc/pgbackrest.conf to manual installation instructions.

Documentation Improvements:

  • Move repository options into a separate section in command/command-line help. (Suggested by Stephen Frost.)

v1.20 Release Notes

Critical 8.3/8.4 Bug Fix

Released June 27, 2017

IMPORTANT NOTE: PostgreSQL 8.3 and 8.4 installations utilizing tablespaces should upgrade immediately from any v1 release and run a full backup. A bug prevented tablespaces from being backed up on these versions only. PostgreSQL ≥ 9.0

Bug Fixes:

  • Fixed an issue that prevented tablespaces from being backed up on PostgreSQL ≤ 8.4.
  • Fixed missing flag in C library build that resulted in a mismatched binary on 32-bit systems. (Reported by Adrian Vondendriesch.)

Features:

  • Add s3-repo-ca-path and s3-repo-ca-file for custom CAs and systems where IO::Socket::SSL cannot find CAs automatically, such as RHEL7. (Suggested by Scott Frazer.)

Test Suite Features:

  • Add documentation builds to CI.

v1.19 Release Notes

S3 Support

Released June 12, 2017

Bug Fixes:

  • Fixed the info command so the WAL archive min/max displayed is for the current database version. (Fixed by Cynthia Shang. Reviewed by David Steele.)
  • Fix backup to reset backup-standby when the standby is unconfigured or unreachable. The backup then runs on the primary. (Fixed by Cynthia Shang. Reviewed by David Steele.)
  • Fixed config warnings raised from a remote process causing errors in the master process. (Fixed by Cynthia Shang. Reviewed by David Steele.)

Features:

  • Amazon S3 repository support. (Reviewed by Cynthia Shang.)

Documentation Bug Fixes:

  • Changed invalid max-archive-mb option in configuration reference to archive-queue-max.
  • Fixed missing sudo in installation section. (Fixed by Lætitia. Reviewed by David Steele.)

v1.18 Release Notes

Stanza Upgrade, Refactoring, and Locking Improvements

Released April 12, 2017

Bug Fixes:

  • Fix write locks created by read-only operations with local workers, such as restore. These locks could interfere with parallel archive-push. (Reported by Jens Wilke.)

Features:

  • Add stanza-upgrade to update a stanza after a PostgreSQL major version upgrade. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Added validation of pgbackrest.conf to display warnings if options are not valid or are not in the correct section. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Improvements:

  • Simplify locking scheme. Only the master process now holds write locks for archive-push and backup. Previously, all local and remote workers held them.
  • Do not set timestamps of files in the backup directories to match timestamps in the cluster directory. This was originally done to enable backup resume, but that process is now implemented with checksums.
  • Improved error message when the restore command detects the presence of postmaster.pid. (Suggested by Yogesh Sharma.)
  • Renumber return codes between 25 and 125 to avoid PostgreSQL interpreting some as fatal signal exceptions. (Suggested by Yogesh Sharma.)

v1.17 Release Notes

Page Checksum Bug Fix

Released March 13, 2017

Bug Fixes:

  • Fixed an issue where newly initialized (but unused) pages would cause page checksum warnings. (Reported by Stephen Frost.)

v1.16 Release Notes

Page Checksum Improvements, CI, and Package Testing

Released March 2, 2017

Bug Fixes:

  • Fixed an issue where tables over 1GB would report page checksum warnings after the first segment. (Reported by Stephen Frost.)
  • Fixed an issue where databases created with a non-default tablespace would raise bogus warnings about pg_filenode.map and pg_internal.init not being page aligned. (Reported by blogh.)

Test Suite Features:

  • Continuous integration using travis-ci.
  • Automated builds of Debian packages for all supported distributions.

v1.15 Release Notes

Refactoring and Bug Fixes

Released February 13, 2017

Bug Fixes:

  • Fix a v1.13 regression that could fail backups when files disappeared during manifest creation, for example after tables were dropped. (Reported by Navid Golpayegani.)

v1.14 Release Notes

Refactoring and Bug Fixes

Released February 13, 2017

Bug Fixes:

  • Fix archive-push errors that were not retried. They caused repeated PostgreSQL errors until the .error file was deleted manually. (Reported by Jens Wilke.)
  • Fix a parallel archive race condition. Simultaneous attempts to create the same path caused an error. (Reported by Jens Wilke.)

Improvements:

  • Improved performance of wal archive min/max provided by the info command. (Suggested by Jens Wilke.)

Documentation Features:

  • Updated async archiving documentation to more accurately describe how the new method works and how it differs from the old method. (Suggested by Jens Wilke.)

v1.13 Release Notes

Parallel Archiving, Stanza Create, Improved Info and Check

Released February 5, 2017

IMPORTANT NOTE: This asynchronous archive implementation stopped copying WAL to a separate queue. After upgrading to 1.13, WAL remaining in the old queue would be abandoned and not archived. Before upgrading, stop archiving with archive_command = false. Run pgbackrest --stanza=[stanza-name] archive-push to drain the queue, and wait for completion. Check that [spool-path]/archive/[stanza-name]/out is empty. Then install 1.13 and restore the original archive_command.

IMPORTANT NOTE: This release made stanza-create mandatory before backups or archiving for a new stanza. Existing stanzas did not need this command.

Bug Fixes:

  • Fixed const assignment giving compiler warning in C library. (Fixed by Adrian Vondendriesch. Reviewed by David Steele.)
  • Fixed a few directory syncs that were missed for the --repo-sync option.
  • Fixed an issue where a missing user/group on restore could cause an “uninitialized value” error in File->owner(). (Reported by Leonardo GG Avellar.)
  • Fixed an issue where protocol mismatch errors did not output the expected value.
  • Fixed a spurious archive-get log message that indicated an exit code of 1 was an abnormal termination.

Features:

  • Improved, multi-process implementation of asynchronous archiving.
  • Improved stanza-create command so that it can repair broken repositories in most cases and is robust enough to be made mandatory. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Allow check to run on a standby. Only basic checks run because a replica cannot execute pg_switch_xlog(). (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Added archive and backup WAL ranges to the info command.
  • Added warning to update pg_tablespace.spclocation when remapping tablespaces in PostgreSQL < 9.2. (Contributed by blogh. Reviewed by David Steele.)
  • Remove remote lock requirements for the archive-get, restore, info, and check commands since they are read-only operations. (Suggested by Michael Vitale.)

Improvements:

  • Log file banner is not output until the first log entry is written. (Suggested by Jens Wilke.)
  • Reduced the likelihood of torn pages causing a false positive in page checksums by filtering on start backup LSN.
  • Remove Intel-specific optimization from C library build flags. (Contributed by Adrian Vondendriesch. Reviewed by David Steele.)
  • Remove --lock option. This option was introduced before the lock directory could be located outside the repository and is now obsolete.
  • Added --log-timestamp option to allow timestamps to be suppressed in logging. This is primarily used to avoid filters in the automated documentation.
  • Return proper error code when unable to convert a relative path to an absolute path. (Suggested by Yogesh Sharma.)

Documentation Features:

  • Added documentation to the User Guide for the process-max option. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v1.12 Release Notes

Page Checksums, Configuration, and Bug Fixes

Released December 12, 2016

IMPORTANT NOTE: Earlier releases accepted command-line options that were invalid for the selected command. This release reports errors for those options. Check your command lines carefully to prevent disruption.

Bug Fixes:

  • Fixed an issue where options that were invalid for the specified command could be provided on the command-line without generating an error. Previously, these options were ignored without changing behavior. They now produce an error to prevent confusion. (Reported by Nikhilchandra Kulkarni.)
  • Fixed an issue where internal symlinks were not being created for tablespaces in the repository. This affected manual, in-place cluster startup from filesystem snapshots. Normal backups and restores were unaffected.
  • Fixed an issue that prevented errors from being output to the console before the logging system was initialized, i.e. while parsing options. Error codes were correct, so failed processes did not appear successful. (Reported by Adrian Vondendriesch.)
  • Fixed an issue where the db-port option specified on the backup server would not be properly passed to the remote unless it was from the first configured database. (Reported by Michael Vitale.)

Features:

  • Add --checksum-page to validate data-file page checksums on PostgreSQL >= 9.3 when cluster checksums are enabled. This requires a C library that might initially be absent from OS packages. Enable the option automatically when both the library and cluster checksums are available. (Suggested by Stephen Frost.)
  • Added the --repo-link option to allow internal symlinks to be suppressed when the repository is located on a filesystem that does not support symlinks. This preserves pgBackRest functions but omits latest and internal tablespace symlinks. Their absence affects manual, in-place cluster startup from filesystem snapshots.
  • Added the --repo-sync option to allow directory syncs in the repository to be disabled for file systems that do not support them, e.g. NTFS.
  • Added a predictable log entry to signal that a command has completed successfully. For example a backup ends successfully with: INFO: backup command end: completed successfully. (Suggested by Jens Wilke.)

Improvements:

  • Copy pg_control with other files instead of separately at the end. The backup command does not need special ordering. The restore command copies to a temporary file and renames it at completion.

Documentation Bug Fixes:

  • Fixed an issue that suppressed exceptions in PDF builds.
  • Fixed regression in section links introduced in v1.10.

Documentation Features:

  • Added Retention to QuickStart section.

v1.11 Release Notes

Bug Fix for Asynchronous Archiving Efficiency

Released November 17, 2016

Bug Fixes:

  • Fixed an issue where asynchronous archiving was transferring one file per execution instead of transferring files in batches. The v1.09 regression reduced efficiency only. Asynchronous mode still archived all WAL segments correctly. (Reported by Stephen Frost.)

v1.10 Release Notes

Stanza Creation and Minor Bug Fixes

Released November 8, 2016

Bug Fixes:

  • Fixed an issue where a backup could error if no changes were made to a database between backups and only pg_control changed.
  • Fixed an issue where tablespace paths with the same prefix would cause an invalid link error. (Reported by Nikhilchandra Kulkarni.)

Features:

  • Added the stanza-create command to formalize creation of stanzas in the repository. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Improvements:

  • Removed extraneous use lib directives from Perl modules. (Suggested by Devrim Gündüz.)

v1.09 Release Notes

9.6 Support, Configurability, and Bug Fixes

Released October 10, 2016

Bug Fixes:

  • Fixed the check command to prevent an error message from being logged if the backup directory does not exist. (Fixed by Cynthia Shang. Reviewed by David Steele.)
  • Fixed error message to properly display the archive command when an invalid archive command is detected. (Reported by Jason O’Donnell.)
  • Fixed an issue where the async archiver would not be started if archive-push did not have enough space to queue a new WAL segment. The queue then required manual action, such as a direct archive-push call, to clear it. PostgreSQL still receives errors when space is insufficient. However, the asynchronous process now starts to free space. (Reported by Jens Wilke.)
  • Fix remote timeouts during local checksum calculation in resume or restore. Without file transfers, the remote became idle. (Reported by Jens Wilke.)

Features:

  • Non-exclusive backups will automatically be used on PostgreSQL 9.6.
  • Added the cmd-ssh option to allow the ssh client to be specified. (Suggested by Jens Wilke.)
  • Added the log-level-stderr option to control whether console log messages are sent to stderr or stdout. The new default, warn, changes previous behavior. Set log-level-stderr=off to preserve the old behavior. (Suggested by Sascha Biberhofer.)
  • Set application_name to "pgBackRest [command]" for database connections. (Suggested by Jens Wilke.)
  • Check that archive_mode is enabled when archive-check option enabled.

Improvements:

  • Clarified error message when unable to acquire pgBackRest advisory lock to make it clear that it is not a PostgreSQL backup lock. (Suggested by Jens Wilke.)
  • pgBackRest version number included in command start INFO log output.
  • Process ID logged for local process start/stop INFO log output.

Documentation Features:

  • Added archive-timeout option documentation to the user guide. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v1.08 Release Notes

Bug Fixes and Log Improvements

Released September 14, 2016

Bug Fixes:

  • Fixed an issue where local processes were not disconnecting when complete and could later timeout. (Reported by Todd Vernick.)
  • Fixed an issue where the protocol layer could timeout while waiting for WAL segments to arrive in the archive. (Reported by Todd Vernick.)

Improvements:

  • Cache file log output until the file is created to create a more complete log.

v1.07 Release Notes

Thread to Process Conversion and Bug Fixes

Released September 7, 2016

Bug Fixes:

  • Fixed an issue where tablespaces were copied from the primary during standby backup.
  • Fixed the check command so backup info is checked remotely and not just locally. (Fixed by Cynthia Shang. Reviewed by David Steele.)
  • Fixed an issue where retention-archive was not automatically being set when retention-archive-type=diff, resulting in a less aggressive than intended expiration of archive. (Fixed by Cynthia Shang. Reviewed by David Steele.)

Features:

  • Converted Perl threads to processes to improve compatibility and performance.
  • Exclude contents of $PGDATA/pg_replslot directory so that replication slots on the primary do not become part of the backup.
  • The archive-start and archive-stop settings are now filled in backup.manifest even when archive-check=n. (Suggested by Jens Wilke.)
  • Additional warnings when archive retention settings may not have the intended effect or would allow indefinite retention. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Experimental support for non-exclusive backups in PostgreSQL 9.6 rc1. Later release candidates could change control/catalog/WAL versions and break compatibility. pgBackRest updates were planned for each release.

Documentation Bug Fixes:

  • Fixed minor documentation reproducibility issues related to binary paths.

Documentation Features:

  • Documentation for archive retention. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v1.06 Release Notes

Backup from Standby and Bug Fixes

Released August 25, 2016

Bug Fixes:

  • Fixed an issue where a tablespace link that referenced another link would not produce an error, but instead skip the tablespace entirely. (Reported by Michael Vitale.)
  • Fixed an issue where options that should not allow multiple values could be specified multiple times in pgbackrest.conf without an error being raised. (Reported by Michael Vitale.)
  • Fixed an issue where the protocol-timeout option was not automatically increased when the db-timeout option was increased. (Reported by Todd Vernick.)

Features:

  • Backup from a standby cluster. A primary connection remains necessary to start/stop backup and copy unreplicated files. Most files come from the standby to reduce primary load.
  • More flexible configuration for databases. Configure both primary and standby on the backup server. pgBackRest detects the primary automatically. With a separate backup server, failover then requires no backup configuration changes.
  • Exclude directories during backup that are cleaned, recreated, or zeroed by PostgreSQL at startup. These include pgsql_tmp and pg_stat_tmp. The postgresql.auto.conf.tmp file is now excluded in addition to files that were already excluded: backup_label.old, postmaster.opts, postmaster.pid, recovery.conf, recovery.done.
  • Experimental support for non-exclusive backups in PostgreSQL 9.6 beta4. Later beta changes to control/catalog/WAL versions could break compatibility. pgBackRest updates were planned for each release.

Improvements:

  • Improve error message for links that reference links in manifest build.
  • Added hints to error message when relative paths are detected in archive-push or archive-get.
  • Improve backup log messages to indicate which host the files are being copied from.

v1.05 Release Notes

Bug Fix for Tablespace Link Checking

Released August 9, 2016

Bug Fixes:

  • Fix tablespace paths incorrectly identified as $PGDATA subdirectories because their names contained $PGDATA. Also strengthen relative path checks. (Reported by Chris Fort.)

Documentation Features:

  • Added documentation for scheduling backups with cron. (Contributed by Cynthia Shang. Reviewed by David Steele.)

Documentation Improvements:

  • Moved the backlog from the pgBackRest website to the GitHub repository wiki. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v1.04 Release Notes

Various Bug Fixes

Released July 30, 2016

Bug Fixes:

  • Fix an unnecessary remote process that could cause threaded backup/restore timeouts or lock conflicts. (Reported by Michael Vitale.)
  • Require db-path for check. Previously, its absence caused an assertion instead of a useful error message. (Reported by Michael Vitale.)
  • Fixed check command to throw an error when database version/id does not match that of the archive. (Fixed by Cynthia Shang. Reviewed by David Steele.)
  • Fix a remote starting another remote when the database server’s pgbackrest.conf lacked backup-host. (Reported by Lardière Sébastien.)
  • Fixed an issue where the contents of pg_xlog were being backed up if the directory was symlinked. This didn’t cause any issues during restore but was a waste of space.
  • Fixed an invalid log() call in lock routines.

Features:

  • Experimental support for non-exclusive backups in PostgreSQL 9.6 beta3. Later beta changes to control/catalog/WAL versions could break compatibility. pgBackRest updates were planned for each release.

Improvements:

  • Suppress banners on SSH protocol connections.
  • Improved remote error messages to identify the host where the error was raised.
  • All remote types now take locks. The exceptions date to when the test harness and pgBackRest were running in the same VM and no longer apply.

Documentation Features:

  • Added clarification on why the default for the backrest-user option is backrest. (Suggested by Michael Vitale.)
  • Updated information about package availability on supported platforms. (Suggested by Michael Vitale.)

v1.03 Release Notes

Check Command and Bug Fixes

Released July 2, 2016

Bug Fixes:

  • Fix delayed keep-alives when multi-threaded backup processes many small files. They were also completely absent from single/multi-threaded backup resume and restore checksumming. (Reported by Janice Parkinson, Chris Barber.)
  • Fix manual expire calls failing when db-host was set. Automatic expiration after backup was unaffected. (Reported by Chris Barber.)
  • Fixed an issue where validation was being running on archive_command even when the archive-check option was disabled.

Features:

  • Added check command to validate that pgBackRest is configured correctly for archiving and backups. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Added the protocol-timeout option. Previously protocol-timeout was set as db-timeout + 30 seconds.
  • Failure to shutdown remotes at the end of the backup no longer throws an exception. Instead a warning is generated that recommends a higher protocol-timeout.
  • Experimental support for non-exclusive backups in PostgreSQL 9.6 beta2. Later beta changes to control/catalog/WAL versions could break compatibility. pgBackRest updates were planned for each release.

Improvements:

  • Improved handling of users/groups captured during backup that do not exist on the restore host. Also explicitly handle the case where user/group is not mapped to a name.
  • Option handling is now far more strict. Previously, commands could use unassigned options. This particularly affected backup-host and db-host, which determine locality.

Documentation Improvements:

  • Allow a static date to be used for documentation to generate reproducible builds. (Suggested by Adrian Vondendriesch.)
  • Added documentation for asynchronous archiving to the user guide. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Recommended install location for pgBackRest modules is now /usr/share/perl5 since /usr/lib/perl5 has been removed from the search path in newer versions of Perl.
  • Added instructions for removing prior versions of pgBackRest.

v1.02 Release Notes

Bug Fix for Perl 5.22

Released June 2, 2016

Bug Fixes:

  • Fix usage of sprintf() due to new constraints in Perl 5.22. Parameters not referenced in the format string are no longer allowed. (Fixed by Adrian Vondendriesch. Reviewed by David Steele.)

Documentation Bug Fixes:

  • Fixed syntax that was not compatible with Perl 5.2X. (Fixed by Christoph Berg, Adrian Vondendriesch. Reviewed by David Steele.)
  • Fixed absolute paths that were used for the PDF logo. (Reported by Adrian Vondendriesch.)

Documentation Features:

  • Release notes are now broken into sections so that bugs, features, and refactors are clearly delineated. An “Additional Notes” section has been added for changes to documentation and the test suite that do not affect the core code.
  • Added man page generation. (Contributed by Adrian Vondendriesch, David Steele.)
  • Convert the change log, formerly the last Markdown-only document, for the standard renderers. Publish it on the website under the name “Releases”. (Contributed by Cynthia Shang. Reviewed by David Steele.)

v1.01 Release Notes

Enhanced Info, Selective Restore, and 9.6 Support

Released May 17, 2016

Features:

  • Enhanced text output of info command to include timestamps, sizes, and the reference list for all backups. (Contributed by Cynthia Shang. Reviewed by David Steele.)
  • Allow selective restore of databases from a cluster backup. Restoring selected databases can save substantial space and time. Other databases are inaccessible. Drop them manually to remove them from the shared catalogue. (Reviewed by Cynthia Shang, Greg Smith, Stephen Frost. Suggested by Stephen Frost.)
  • Experimental support for non-exclusive backups in PostgreSQL 9.6 beta1. Later beta changes to control/catalog/WAL versions could break compatibility. pgBackRest updates were planned for each release. (Reviewed by Cynthia Shang.)

v1.00 Release Notes

New Repository Format and Configuration Scheme, Link Support

Released April 14, 2016

IMPORTANT NOTE: This release broke compatibility with earlier pgBackRest versions. It changed the manifest format, on-disk structure, configuration scheme, and executable/path names. Create a new repository for this version. Keep the old repository temporarily in case you need to restore from it. Older repositories require their original pgBackRest version.

The name changes allow 1.00 and an earlier version to be installed together. See the following notes for details.

Features:

  • Introduce a simpler configuration scheme. For a simple configuration, place all options in stanza. See the User Guide and Configuration Reference for details. Options that are shared between stanzas can be placed in the [global] section. More complex configurations can still make use of command sections though this should be a rare use case. (Suggested by Michael Renner.)
  • Make repo-path identify the backup and archive repository, whether local or remote. Remove repo-remote-path. The new spool-path option can be used to define a location for queueing WAL segments when archiving asynchronously. A local repository is no longer required.
  • The default configuration filename is now pgbackrest.conf instead of pg_backrest.conf. This was done for consistency with other naming changes but also to prevent old config files from being loaded accidentally when migrating to 1.00. (Suggested by Michael Renner, Stephen Frost.)
  • The default repository name was changed from /var/lib/backup to /var/lib/pgbackrest. (Suggested by Michael Renner, Stephen Frost.)
  • Lock files are now stored in /tmp/pgbackrest by default. The preferred location, /run/pgbackrest, requires init scripts absent from this release. The lock-path option can be used to configure the lock directory.
  • Store logs in /var/log/pgbackrest by default. Remove date suffixes so logrotate can manage them. The log-path option can be used to configure the log directory. (Suggested by Stephen Frost.)
  • Executable filename changed from pg_backrest to pgbackrest. (Suggested by Michael Renner, Stephen Frost.)
  • All files and directories linked from PGDATA are now included in the backup. By default links will be restored directly into PGDATA as files or directories. The --link-all option can be used to restore all links to their original locations. The --link-map option can be used to remap a link to a new location.
  • Removed --tablespace option and replaced with --tablespace-map-all option which should more clearly indicate its function.
  • Added detail log level which will output more information than info without being as verbose as debug.

Pre-Stable Releases

v0.92 Release Notes

Command-line Repository Path Fix

Released April 6, 2016

Bug Fixes:

  • Fix the master passing --repo-remote-path instead of --repo-path to the remote. This created locks in the default repository directory, /var/lib/backup, and usually failed. This was only an issue when --repo-remote-path was defined on the command line rather than in pg_backrest.conf. (Reported by Jan Wieck.)

v0.91 Release Notes

Tablespace Bug Fix and Minor Enhancements

Released March 22, 2016

IMPORTANT BUG FIX FOR TABLESPACES: Version 0.90 accidentally changed the repository format. Backups with tablespaces were no longer valid PostgreSQL data directories on disk. This affected direct-copy restores, but not restores through the restore command. However, this fix breaks compatibility with older tablespace backups for every restore method. pgBackRest reports an error and refuses to restore them.

Immediately after installing 0.91, take a new full backup of each cluster with tablespaces. To restore an older backup, use the pgBackRest version that created it.

Bug Fixes:

  • Fixed repository incompatibility introduced in pgBackRest 0.90. (Reported by Evan Benoit.)

Features:

  • Copy global/pg_control last during backups.
  • Write .info and .manifest files to temp before moving them to their final locations and fsync’ing.
  • Rename --no-start-stop option to --no-online.

Test Suite Features:

  • Static source analysis using Perl-Critic, currently passes on gentle.

v0.90 Release Notes

9.5 Support, Various Enhancements, and Minor Bug Fixes

Released February 7, 2016

Bug Fixes:

  • Fixed an issue where specifying --no-archive-check would throw a configuration error. (Reported by Jason O’Donnell.)
  • Fixed an issue where a temp WAL file left over after a well-timed system crash could cause the next archive-push to fail.
  • Allow retention-archive below backup retention (retention-full or retention-diff) without requiring archive-copy=n. The WAL required to make the backups that fall outside of archive retention consistent will be preserved in the archive. However, in this case PITR will not be possible for the backups that fall outside of archive retention.

Features:

  • For tablespace backup and restore, operate only on the subdirectory for the current PostgreSQL version. Multiple versions can share a tablespace, especially during binary upgrades. This prevents unnecessary backup copies and deletion of other versions during restore. It applies to PostgreSQL >= 9.0; earlier versions could not share tablespace directories.
  • Generate an error when archive-check=y but archive_command does not execute pg_backrest. (Contributed by Jason O’Donnell. Reviewed by David Steele.)
  • Improved error message when repo-path or repo-remote-path does not exist.
  • Added checks for --delta and --force restore options to ensure that the destination is a valid $PGDATA directory. pgBackRest will check for the presence of PG_VERSION or backup.manifest (left over from an aborted restore). If neither file exists, disable --delta and --force. Continue only when $PGDATA and tablespace directories are empty; otherwise, stop the restore.
  • When restore --set=latest (the default) the actual backup restored will be output to the log.
  • Support for PostgreSQL 9.5 partial WAL segments and recovery_target_action setting. The archive_mode = 'always' setting is not yet supported.
  • Support for recovery_target = 'immediate' recovery setting introduced in PostgreSQL 9.4.
  • The following tablespace checks have been added: paths or files in pg_tblspc, relative links in pg_tblspc, tablespaces in $PGDATA. All three will generate errors.

v0.89 Release Notes

Timeout Bug Fix and Restore Read-Only Repositories

Released December 24, 2015

Bug Fixes:

  • Fixed an issue where longer-running backups/restores would timeout when remote and threaded. Use keep-alives so the main process remote does not time out while thread remotes work. The error message for timeouts was also improved to make debugging easier. (Reported by Stephen Frost.)

Features:

  • Allow restores to be performed on a read-only repository by using --no-lock and --log-level-file=off. The --no-lock option can only be used with restores.

v0.88 Release Notes

Documentation and Minor Bug Fixes

Released November 22, 2015

Bug Fixes:

  • Fixed an issue where the start/stop commands required the --config option. (Reported by Dmitry Didovicher.)
  • Fixed an issue where log files were being overwritten instead of appended. (Reported by Stephen Frost, Dmitry Didovicher.)
  • Fixed an issue where backup-user was not optional.

Features:

  • Symlinks are no longer created in backup directories in the repository. These symlinks could point virtually anywhere and potentially be dangerous. Symlinks are still recreated during a restore. (Suggested by Stephen Frost.)
  • Added better messaging for backup expiration. Full and differential backup expirations are logged on a single line along with a list of all dependent backups expired.
  • Archive retention is automatically set to full backup retention if not explicitly configured.

Documentation Features:

  • Added documentation in the user guide for delta restores, expiration, dedicated backup hosts, starting and stopping pgBackRest, and replication.

v0.87 Release Notes

Website and User Guide

Released October 28, 2015

Features:

  • The backup_label.old and recovery.done files are now excluded from backups.

Documentation Features:

  • Added a new user guide that covers pgBackRest basics and some advanced topics including PITR. Further documentation was planned. (Contributed by David Steele, Stephen Frost. Reviewed by Michael Renner, Cynthia Shang, Eric Radman, Dmitry Didovicher.)

v0.85 Release Notes

Start/Stop Commands and Minor Bug Fixes

Released October 8, 2015

Bug Fixes:

  • Fixed an issue where an error could be returned after a backup or restore completely successfully.
  • Fixed an issue where a resume would fail if temp files were left in the root backup directory when the backup failed. This scenario was likely if the backup process got terminated during the copy phase.

Features:

  • Add stop and start to control pgBackRest execution when PostgreSQL is shut down or the system needs inactivity for another reason.
  • Experimental support for PostgreSQL 9.5 beta1. Future control-version or WAL-magic changes could break support; updates were planned for each pgBackRest release. All regression tests passed except --target-resume, whose behavior changed in 9.5. Tests for .partial WAL segments were not yet available.

v0.82 Release Notes

Refactoring, Command-line Help, and Minor Bug Fixes

Released September 14, 2015

Bug Fixes:

  • Fixed an issue where resumed compressed backups were not preserving existing files.
  • Fixed an issue where resume and incr/diff would not ensure that the prior backup had the same compression and hardlink settings.
  • Fixed an issue where a cold backup using --no-start-stop could be started on a running PostgreSQL cluster without --force specified.
  • Fixed an issue where a thread could be started even when none were requested.
  • Fixed an issue where the pgBackRest version number was not being updated in backup.info and archive.info after an upgrade/downgrade.
  • Fixed an issue where the info command was throwing an exception when the repository contained no stanzas. (Reported by Stephen Frost.)
  • Fixed an issue where the PostgreSQL pg_stop_backup() NOTICEs were being output to stderr. (Reported by Stephen Frost.)

Features:

  • Experimental support for PostgreSQL 9.5 alpha2. Future control-version or WAL-magic changes could break support; updates were planned for each pgBackRest release. All regression tests passed except --target-resume, whose behavior changed in 9.5. Tests for .partial WAL segments were not yet available.

Improvements:

  • Renamed recovery-setting option and section to recovery-option to be more consistent with pgBackRest naming conventions.
  • Added dynamic module loading to speed up commands, especially asynchronous archiving.

Documentation Features:

  • Command-line help is now extracted from the same XML source that is used for the other documentation and includes much more detail.

v0.80 Release Notes

DBI Support, Stability, and Convenience Features

Released August 9, 2015

Bug Fixes:

  • Fixed an issue that caused the formatted timestamp for both the oldest and newest backups to be reported as the current time by the info command. Only text output was affected – json output reported the correct epoch values. (Reported by Michael Renner.)
  • Fixed protocol issue that was preventing ssh errors (especially on connection) from being logged.

Features:

  • The repository is now created and updated with consistent directory and file modes. By default umask is set to 0000 but this can be disabled with the neutral-umask setting. (Suggested by Cynthia Shang.)
  • Added the stop-auto option to allow failed backups to automatically be stopped when a new backup starts.
  • Added the db-timeout option to limit the amount of time pgBackRest will wait for pg_start_backup() and pg_stop_backup() to return.
  • Remove pg_control file at the beginning of the restore and copy it back at the very end. This prevents the possibility that a partial restore can be started by PostgreSQL.
  • Check consistency between db-path and db-port. Compare the cluster-reported data_directory with db-path. Also compare the reported version with pg_control. The db-socket-path setting is checked to be sure it is an absolute path.
  • Experimental support for PostgreSQL 9.5 alpha1. Future control-version or WAL-magic changes could break support; updates were planned for each pgBackRest release. All regression tests passed except --target-resume, whose behavior changed in 9.5. Tests for .partial WAL segments were not yet available.

Improvements:

  • Now using Perl DBI and DBD::Pg for connections to PostgreSQL rather than psql. The cmd-psql and cmd-psql-option settings have been removed and replaced with db-port and db-socket-path. Follow the instructions in the Installation Guide to install DBD::Pg on your operating system.

Test Suite Features:

  • Added vagrant test configurations for Ubuntu 14.04 and CentOS 7.

v0.78 Release Notes

Remove CPAN Dependencies, Stability Improvements

Released July 13, 2015

Improvements:

  • Removed dependency on CPAN packages for multi-threaded operation. Updating threads and Thread::Queue can still be useful, but is no longer required.
  • Modified wait backoff to use a Fibonacci rather than geometric sequence. This will make wait time grow less aggressively while still giving reasonable values.

Test Suite Features:

  • Added vagrant test configurations for Ubuntu 12.04 and CentOS 6.

v0.77 Release Notes

CentOS/RHEL 6 Support and Protocol Improvements

Released June 30, 2015

Features:

  • Added file and directory syncs to the File object for additional safety during backup/restore and archiving. (Suggested by Andres Freund.)
  • Added support for Perl 5.10.1 and OpenSSH 5.3 which are default for CentOS/RHEL 6. (Suggested by Eric Radman.)
  • Improved error message when backup is run without archive_command set and without --no-archive-check specified. (Suggested by Eric Radman.)

v0.75 Release Notes

New Repository Format, Info Command and Experimental 9.5 Support

Released June 14, 2015

IMPORTANT NOTE: This release broke compatibility with earlier pgBackRest versions. It changed the manifest format, on-disk structure, and binary names. Create a new repository for this version. Keep the old repository temporarily in case you need a restore. The pg_backrest.conf file format did not change.

In cron and elsewhere, replace references to pg_backrest.pl with pg_backrest, without the .pl extension.

Features:

  • Added the info command.
  • Logging now uses unbuffered output. This should make log files that are being written by multiple threads less chaotic. (Suggested by Michael Renner.)
  • Experimental support for PostgreSQL 9.5. This may break when the control version or WAL magic changes but will be updated in each release.

Improvements:

  • More efficient file ordering for backup. Files are copied in descending size order so a single thread does not end up copying a large file at the end. This had already been implemented for restore.

v0.70 Release Notes

Stability Improvements for Archiving, Improved Logging and Help

Released June 1, 2015

Bug Fixes:

  • Fixed an issue where archive-copy would fail on an incr/diff backup when hardlink=n. In this case the pg_xlog path does not already exist and must be created. (Reported by Michael Renner.)
  • Fix asynchronous archive-push failing to return 0 when archive-max-mb was reached. Move the asynchronous check after transfer to avoid removing the stop file twice. Add unit tests and clearer error messages for this case. (Reported by Michael Renner.)
  • Fixed a locking issue that could allow multiple operations of the same type against a single stanza. This appeared to be benign in terms of data integrity but caused spurious errors while archiving and could lead to errors in backup/restore. (Reported by Michael Renner.)

Features:

  • Allow duplicate WAL segments to be archived when the checksum matches. This is necessary for some recovery scenarios.
  • Allow comments/disabling in pg_backrest.conf using the # character. Only # characters in the first character of the line are honored. (Suggested by Michael Renner.)
  • Better logging before pg_start_backup() to make it clear when the backup is waiting on a checkpoint. (Suggested by Michael Renner.)
  • Various command behavior and logging fixes. (Reviewed by Michael Renner. Suggested by Michael Renner.)

Improvements:

  • Replaced JSON module with JSON::PP which ships with core Perl.

Documentation Bug Fixes:

  • Various help fixes. (Reviewed by Michael Renner. Reported by Michael Renner.)

v0.65 Release Notes

Improved Resume and Restore Logging, Compact Restores

Released May 11, 2015

Bug Fixes:

  • Fixed an issue where an absolute path was not written into recovery.conf when the restore was run with a relative path.

Features:

  • Better resume support. Check resumed files for changes. Save the manifest more frequently to retain checksums during backup. More unit tests to verify each resume case.
  • Resume is now optional. Use the resume setting or --no-resume from the command line to disable.
  • More info messages during restore. Previously, most of the restore messages were debug level so not a lot was output in the log.
  • Added tablespace setting to allow tablespaces to be restored into the pg_tblspc path. This produces compact restores that are convenient for development, staging, etc. Currently these restores cannot be backed up as pgBackRest expects only links in the pg_tblspc path.

v0.61 Release Notes

Bug Fix for Uncompressed Remote Destination

Released April 21, 2015

Bug Fixes:

  • Fixed a buffering error that could occur on large, highly-compressible files when copying to an uncompressed remote destination. Decompression detected the error and failed the backup without corrupting it. Successful backups from earlier versions should be unaffected.

v0.60 Release Notes

Better Version Support and WAL Improvements

Released April 19, 2015

Bug Fixes:

  • Pushing duplicate WAL now generates an error. This worked before only if checksums were disabled.

Features:

  • Database System IDs are used to make sure that all WAL in an archive matches up. This should help prevent misconfigurations that send WAL from multiple clusters to the same archive.

Test Suite Features:

  • Regression tests working back to PostgreSQL 8.3.

v0.50 Release Notes

Restore and Much More

Released March 25, 2015

Bug Fixes:

  • Fixed broken checksums and now they work with normal and resumed backups. Separate checksums from checksum deltas to simplify the implementation. Track checksum deltas in issue #28.
  • Fixed an issue where a backup could be resumed from an aborted backup that didn’t have the same type and prior backup.

Features:

  • Added restore functionality.
  • All options can now be set on the command-line making pg_backrest.conf optional.
  • De/compression is now performed without threads and checksum/size is calculated in stream. That means file checksums are no longer optional.
  • Added option --no-start-stop to allow backups when Postgres is shut down. If postmaster.pid exists, --force is required. If Postgres is running, the backup will probably be inconsistent. This option mainly supported unit testing but might also have production uses.
  • Checksum for backup.manifest to detect a corrupted/modified manifest.
  • Link latest always points to the last backup. This has been added for convenience and to make restores simpler.

Test Suite Features:

  • More comprehensive unit tests in all areas.

v0.30 Release Notes

Core Restructuring and Unit Tests

Released October 5, 2014

Documentation Features:

  • Added much needed documentation

Test Suite Features:

  • Add broad unit-test coverage for basic operations. Further unit-test work remained necessary.

v0.19 Release Notes

Improved Error Reporting/Handling

Released May 13, 2014

Bug Fixes:

  • Fix file_copy(), which ignored errors by default. Also fix file_exists(), which sometimes reported an existing file as absent. Together, these bugs could have produced a corrupted backup without errors, although this was very unlikely.

v0.18 Release Notes

Return Soft Error When Archive Missing

Released April 13, 2014

Bug Fixes:

  • Return 1 from archive-get for a missing archive file. This distinguishes it from hard errors, such as SSH connection or file-copy failures. PostgreSQL can then recognize a normal end of the archive stream. Gaps in that stream are not considered. (Reported by Stephen Frost.)

v0.17 Release Notes

Warn When Archive Directories Cannot Be Deleted

Released April 3, 2014

Bug Fixes:

  • Report a warning when an archive directory expected to be empty cannot be deleted. Previously, this caused an error. The temporary change allowed processing to continue until a more complete fix was available. Under some conditions, the error prevented the final WAL file from being archived when the first file used a different directory.

v0.16 Release Notes

RequestTTY=yes for SSH Sessions

Released April 1, 2014

Bug Fixes:

  • Add RequestTTY=yes to SSH sessions in an attempt to prevent intermittent lockups.

v0.15 Release Notes

Added archive-get

Released March 29, 2014

Features:

  • Added archive-get functionality to aid in restores.
  • Added option to force a checkpoint when starting the backup, start-fast=y.

v0.11 Release Notes

Minor Fixes

Released March 26, 2014

Bug Fixes:

  • Removed master_stderr_discard option on database SSH connections. There have been occasional lockups and they could be related to issues originally seen in the file code. (Reported by Stephen Frost.)
  • Changed lock file conflicts on backup and expire commands to ERROR. They were set to DEBUG due to a copy-and-paste from the archive locks.

v0.10 Release Notes

Backup and Archiving are Functional

Released March 5, 2014

Features:

  • This release had no restore command, but backup directories were consistent PostgreSQL data directories. Decompress files or disable backup compression. Uncompressed backups on ZFS or similar filesystems support local snapshot restores for logical backups or targeted data recovery.
  • Archiving used one thread. It caused no problems on the authors’ multi-terabyte databases with heavy writes. Use a large WAL volume or asynchronous archiving with a large nearby volume.
  • Backups used multiple threads. Net::OpenSSH appeared not to be 100% thread-safe and very occasionally locked a thread. An overall timeout killed the process to resolve this.
  • A resumed backup lost checksums. With multiple resumes, only the final backup recorded checksums. Checksums from previous backups remained correct, and a full backup reset everything.
  • The backup.manifest used Storable because Config::IniFile appeared to handle large files poorly. The authors wanted human-readable text.

Documentation Features:

  • Documentation existed only in the code and these release notes.

7 - Frequently Asked Questions

Frequently asked questions about pgBackRest backup, restore, configuration, and troubleshooting.

Introduction

These answers cover specific questions that the User Guide and references might not cover. If your issue is absent, check the pgBackRest Issues List in GitHub.


What if I get the “could not find WAL segment” error?

This error has several possible causes:

  • misconfigured archive_command
  • misconfigured pgBackRest configuration files
  • network or permissions issue
  • third party product (e.g. S3, Swift or Minio) configuration issue
  • large amount of WAL queueing to be archived

Check these items:

  • Check PostgreSQL archive_command.
  • Check pgBackRest settings on each host. For example, configure pg* on the repository host and repo* on the PostgreSQL host.
  • Run check with --archive-timeout higher than the configured value or default. This shows whether the WAL queue needs more time to clear. For high WAL volumes, consider asynchronous archiving.

How do I manually purge a backup set?

Use --set to expire a full backup set. See Command Reference: Expire.


How can I configure options independently for each command?

The configuration file can set options independently for each command. See Configure Cluster Stanza for details and option precedence.

For example, the process-max option can be optimized for each command:

[global]
# used where not overridden
process-max=2

[global:backup]
# more cores for backup
process-max=4

[global:restore]
# all the cores for restore
process-max=8

[global:archive-push]
# more cores for archive-push
process-max=3

[global:archive-get]
# fewer cores for archive-get
process-max=1

Can I use dots (periods) in my S3 bucket name?

RFC-2818 does not allow a wildcard to match a dot (.). Therefore, S3 bucket names must not contain dots. A name with dots causes an error such as “unable to find hostname ‘my.backup.bucket.s3.amazonaws.com’ in certificate common name or subject alternative names”.

The exception is repo-s3-uri-style=path, which adds the bucket to the URI instead of the host. The certificate then matches only the endpoint, so dots in the bucket name are permitted. Some S3-compatible object stores do not support path-style URIs.


Where can I find packages for older versions of pgBackRest?

The apt.postgresql.org repository maintains an archive of older versions. Debian also maintains snapshots of all test builds.


Why does a backup attempt fail when backup-standby=y and the standby database is down?

Backups from a standby usually reduce primary load. Moving backups to the primary when the standby fails defeats this purpose. Avoid additional primary load while the system has failures. If a reasonably recent backup exists, keep WAL archiving current and wait until the system is stable for another backup.

If you need a backup, add more standbys or remove backup-standby. For a single backup, use --no-backup-standby on the command line without changing the configuration.


Should I setup my repository on a standby host?

No. Configure primary and standby databases symmetrically so that pgBackRest can handle failover. Otherwise, you must change configuration after failover or risk further problems.

See the Dedicated Repository Host section of the User Guide for more information.


Time-based Point-in-Time Recovery does not appear to work, why?

For time-based Point-in-Time Recovery, choose a backup that completed before the target time. A common error is to omit this check. Without --set, pgBackRest tries to find a backup suitable for --target=. If none matches, restore uses the latest backup. If that backup is newer than the target, PostgreSQL ignores the invalid --target= and replays WAL to the latest available time.

Run info and find a backup whose timestamp stop precedes the target time. Select it with --set during restore. Use --set=BACKUP_LABEL, replacing BACKUP_LABEL with that backup label.

See the Point-in-Time Recovery section of the User Guide for more information.


What does the WAL archive suffix mean?

The suffix is the SHA1 checksum used to verify file integrity. There is no way to omit it.


Does it take longer to restore specific backup types (full, differential, incremental)?

All backup types take the same time to restore under equal disk I/O, network I/O, and other conditions. Restore retrieves files from the backup manifest. Incremental and differential manifests can reference files from earlier backups. Backup creation time varies by type, but database size determines restore time.


How can I export a backup for use in a network-isolated environment?

The repository stores backups, WAL archives, and essential metadata for compression, encryption, and file bundles. Copying a backup with only some WAL files usually fails. It works only under specific, restrictive conditions.

To create a self-contained database export, for example for USB transfer, take a backup with --archive-copy. This includes the WAL segments necessary for consistency. Restore with --type=none and --pg1-path=/your/target/path. The restored PostgreSQL data directory contains all required WAL in pg_wal, similar to pg_basebackup output.

Copy this directory to another system. PostgreSQL should recover without access to the pgBackRest repository.

Recovery from this backup does not switch timelines. The new cluster should not push WAL to the source repository. Network isolation of the new cluster should prevent this problem.

8 - Project Metrics

pgBackRest project code coverage metrics and quality statistics.

Source: pgBackRest project metrics, captured for the 2.59.2 documentation snapshot.


Code Coverage

pgBackRest aims to have complete function/branch/line coverage for the core C code in /src.

Function/line coverage is complete with no exceptions.

Branch coverage excludes branches inside macros and assert() calls. Macros have separate unit tests, so each occurrence does not need testing. Asserts test conditions that should always be true and do not require complete branch coverage.

DirectoryFunctionsBranchesLines
build/common32/32 (100.00%)72/72 (100.00%)268/268 (100.00%)
build/config39/39 (100.00%)564/564 (100.00%)1143/1143 (100.00%)
build/error6/6 (100.00%)22/22 (100.00%)71/71 (100.00%)
build/help13/13 (100.00%)138/138 (100.00%)265/265 (100.00%)
build/postgres8/8 (100.00%)58/58 (100.00%)149/149 (100.00%)
command17/17 (100.00%)104/104 (100.00%)210/210 (100.00%)
command/annotate1/1 (100.00%)12/12 (100.00%)31/31 (100.00%)
command/archive14/14 (100.00%)98/98 (100.00%)189/189 (100.00%)
command/archive/get10/10 (100.00%)208/208 (100.00%)447/447 (100.00%)
command/archive/push12/12 (100.00%)148/148 (100.00%)365/365 (100.00%)
command/backup50/50 (100.00%)790/790 (100.00%)1645/1645 (100.00%)
command/check13/13 (100.00%)106/106 (100.00%)214/214 (100.00%)
command/control4/4 (100.00%)34/34 (100.00%)48/48 (100.00%)
command/expire11/11 (100.00%)274/274 (100.00%)392/392 (100.00%)
command/help8/8 (100.00%)178/178 (100.00%)283/283 (100.00%)
command/info16/16 (100.00%)430/430 (100.00%)748/748 (100.00%)
command/local1/1 (100.00%)—4/4 (100.00%)
command/remote1/1 (100.00%)6/6 (100.00%)18/18 (100.00%)
command/repo9/9 (100.00%)110/110 (100.00%)195/195 (100.00%)
command/restore37/37 (100.00%)726/726 (100.00%)1350/1350 (100.00%)
command/server6/6 (100.00%)24/24 (100.00%)81/81 (100.00%)
command/stanza5/5 (100.00%)106/106 (100.00%)125/125 (100.00%)
command/verify22/22 (100.00%)366/366 (100.00%)733/733 (100.00%)
common146/146 (100.00%)624/624 (100.00%)1350/1350 (100.00%)
common/compress12/12 (100.00%)24/24 (100.00%)80/80 (100.00%)
common/compress/bz213/13 (100.00%)20/20 (100.00%)123/123 (100.00%)
common/compress/gz13/13 (100.00%)26/26 (100.00%)118/118 (100.00%)
common/compress/lz415/15 (100.00%)24/24 (100.00%)116/116 (100.00%)
common/compress/zst13/13 (100.00%)12/12 (100.00%)96/96 (100.00%)
common/crypto32/32 (100.00%)88/88 (100.00%)424/424 (100.00%)
common/error33/33 (100.00%)66/66 (100.00%)179/179 (100.00%)
common/io61/61 (100.00%)182/182 (100.00%)523/523 (100.00%)
common/io/filter31/31 (100.00%)92/92 (100.00%)276/276 (100.00%)
common/io/http58/58 (100.00%)292/292 (100.00%)685/685 (100.00%)
common/io/socket28/28 (100.00%)110/110 (100.00%)339/339 (100.00%)
common/io/tls37/37 (100.00%)122/122 (100.00%)409/409 (100.00%)
common/type335/335 (100.00%)922/922 (100.00%)3123/3123 (100.00%)
config93/93 (100.00%)1025/1026 (99.90%)1652/1652 (100.00%)
db23/23 (100.00%)94/94 (100.00%)301/301 (100.00%)
info48/48 (100.00%)240/240 (100.00%)712/712 (100.00%)
info/manifest10/10 (100.00%)132/132 (100.00%)303/303 (100.00%)
postgres36/36 (100.00%)128/128 (100.00%)333/333 (100.00%)
postgres/interface4/4 (100.00%)10/10 (100.00%)35/35 (100.00%)
protocol60/60 (100.00%)266/266 (100.00%)860/860 (100.00%)
storage68/68 (100.00%)304/304 (100.00%)762/762 (100.00%)
storage/azure26/26 (100.00%)162/162 (100.00%)488/488 (100.00%)
storage/cifs2/2 (100.00%)—6/6 (100.00%)
storage/gcs34/34 (100.00%)176/176 (100.00%)575/575 (100.00%)
storage/posix29/29 (100.00%)165/166 (99.40%)328/328 (100.00%)
storage/remote40/40 (100.00%)128/128 (100.00%)568/568 (100.00%)
storage/s331/31 (100.00%)200/200 (100.00%)663/663 (100.00%)
storage/sftp39/39 (100.00%)408/408 (100.00%)762/762 (100.00%)
TOTAL1705/1705 (100.00%)10616/10618 (99.98%)25163/25163 (100.00%)

C unit test modules in /test/src/module also have complete function and line coverage. The report excludes them.