Skip to main content

PgBackrest

This PostgreSQL container image includes pgBackRest, a reliable and efficient backup and restore solution for PostgreSQL. pgBackRest is built to handle large databases and supports full, differential, and incremental backups, as well as point-in-time recovery.

The image also provides convenience scripts and sensible defaults to simplify using pgBackRest in container environments. To enable pgBackRest in your PostgreSQL container, you can use the following Docker Compose configuration:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
ports:
- "5434:5432"
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
volumes:
- ./.data:/usr/local/pgsql/data
- ./.backup:/usr/local/pgsql/backup

Enable Automatic Backup

We also provide an option to enable automatic backup scheduling using cron syntax. You can configure the automatic backup settings using the following environment variables:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_AUTO_ENABLE: "true"
PGBACKREST_AUTO_FULL_CRON: "00 00 * * *"
PGBACKREST_AUTO_DIFF_CRON: "0 */6 * * *" # Optional: Adjust as needed
PGBACKREST_AUTO_INCR_CRON: "*/15 * * * *" # Optional: Adjust as needed
PGBACKREST_AUTO_TIMEZONE: "Asia/Jakarta" # Optional: Set your desired timezone
volumes:
- ./.data:/usr/local/pgsql/data
- ./.backup:/usr/local/pgsql/backup

Automatic Backup on Replicas

By default, automatic backups run only on the primary node. Set PGBACKREST_AUTO_PRIMARY_ONLY: "false" to allow replicas to run scheduled backups:

services:
postgresql-replica:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
environment:
PGBACKREST_ENABLE: "true"
PGBACKREST_AUTO_ENABLE: "true"
PGBACKREST_AUTO_PRIMARY_ONLY: "false" # Allow replicas to run scheduled backups
PGBACKREST_AUTO_FULL_CRON: "00 02 * * *"

This is useful when:

  • Primary has slow disk I/O and you want to offload backup to faster replicas
  • Replicas have access to the backup repository
  • Using standby backup mode (PGBACKREST_BACKUP_STANDBY: "prefer")

Backup Performance & Verification Options

You can fine-tune backup behavior with the following environment variables:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_AUTO_ENABLE: "true"
PGBACKREST_BACKUP_START_FAST: "true" # Faster full backups with checkpoint
PGBACKREST_BACKUP_STOP_AUTO: "true" # Clean shutdown after backup
PGBACKREST_BACKUP_VERIFY: "true" # Verify backup after creation (default: true)
PGBACKREST_PROCESS_MAX: "4" # Parallel backup/restore threads
VariableDefaultDescription
PGBACKREST_BACKUP_START_FASTfalseForce a checkpoint before backup for faster completion
PGBACKREST_BACKUP_STOP_AUTOfalseStop PostgreSQL automatically after backup
PGBACKREST_BACKUP_VERIFYtrueVerify backup after creation to ensure integrity
PGBACKREST_PROCESS_MAX-Number of parallel processes for backup/restore (auto-detected if not set)

Backup Storage Configuration

Configure how backups are stored and retained:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_REPO_RETENTION_FULL_TYPE: "full" # WAL retention type
PGBACKREST_REPO_RETENTION_HISTORY: "365" # Keep backup history for 1 year
PGBACKREST_ARCHIVE_ASYNC: "true" # Async WAL archiving for performance
PGBACKREST_SPARSE_TABLE: "true" # Faster backup on supported filesystems
PGBACKREST_REPO_COMPRESSION: "zstd" # Backup compression (gzip/lz4/zstd)
VariableDefaultDescription
PGBACKREST_REPO_RETENTION_FULL_TYPE-WAL retention type: full (full backups only) or backup (include differential WAL)
PGBACKREST_ARCHIVE_ASYNCfalseEnable async WAL archiving for better performance
PGBACKREST_SPARSE_TABLEfalseEnable sparse table support for faster backups on supported filesystems
PGBACKREST_REPO_COMPRESSIONgzipBackup compression type: gzip, lz4, or zstd

Backup to S3-Compatible Storage

The image also supports backing up to S3-compatible storage solutions. You can configure the S3 repository settings using environment variables. Here's an example configuration for backing up to an S3-compatible service:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
ports:
- "5434:5432"
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_REPO_TYPE: s3
PGBACKREST_REPO_S3_BUCKET: test-pgbackrest
PGBACKREST_REPO_S3_ENDPOINT: minio.example.com
PGBACKREST_REPO_S3_REGION: id-jakarta-1
PGBACKREST_REPO_S3_KEY: <access-key>
PGBACKREST_REPO_S3_KEY_SECRET: <secret-key>
PGBACKREST_REPO_S3_URI_STYLE: path
PGBACKREST_REPO_PATH: /example # Optional: Path inside the bucket
# Optional, can be combined with Auto Backup Configuration
# PGBACKREST_AUTO_ENABLE: "true"
# PGBACKREST_AUTO_FULL_CRON: "00 00 * * *"
# PGBACKREST_AUTO_DIFF_CRON: "0 */6 * * *"
# PGBACKREST_AUTO_INCR_CRON: "*/15 * * * *"
# PGBACKREST_AUTO_TIMEZONE: "Asia/Jakarta"
volumes:
- ./.data:/usr/local/pgsql/data
- ./.backup:/usr/local/pgsql/backup

S3 Extended Options

Additional S3 configuration options:

services:
postgresql:
environment:
# ... base S3 config ...
PGBACKREST_REPO_S3_BUCKET_REGION: "ap-indonesia-1" # Explicit bucket region
PGBACKREST_REPO_S3_ENDPOINT_FLEXIBLE: "true" # Allow flexible endpoint matching
PGBACKREST_REPO_S3_VERIFY_TLS: "true" # Verify TLS certificates
PGBACKREST_REPO_S3_CA_FILE: "/path/to/ca-bundle.crt" # Custom CA bundle file
PGBACKREST_REPO_S3_CA_PATH: "/path/to/ca-bundle/" # Custom CA bundle path
VariableDescription
PGBACKREST_REPO_S3_BUCKET_REGIONExplicit S3 bucket region (useful for cross-region access)
PGBACKREST_REPO_S3_ENDPOINT_FLEXIBLEEnable flexible endpoint matching for S3-compatible providers
PGBACKREST_REPO_S3_VERIFY_TLSVerify TLS certificates (default: true)
PGBACKREST_REPO_S3_CA_FILEPath to CA bundle file for TLS verification
PGBACKREST_REPO_S3_CA_PATHPath to CA bundle directory for TLS verification

Backup to SFTP Server

The image also supports backing up to an SFTP server. You can configure the SFTP repository settings using environment variables. Here's an example configuration for backing up to an SFTP server:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
ports:
- "5434:5432"
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_REPO_TYPE: sftp
PGBACKREST_REPO_SFTP_HOST: 10.11.12.1
PGBACKREST_REPO_SFTP_HOST_PORT: 22
PGBACKREST_REPO_SFTP_HOST_USER: devops
PGBACKREST_REPO_SFTP_PRIVATE_KEY_FILE: /home/postgres/.ssh/id_ed25519
PGBACKREST_REPO_SFTP_PUBLIC_KEY_FILE: /home/postgres/.ssh/id_ed25519.pub
PGBACKREST_REPO_PATH: /home/devops/pgbackrest
PGBACKREST_REPO_SFTP_HOST_KEY_HASH_TYPE: sha256
PGBACKREST_REPO_SFTP_HOST_KEY_CHECK_TYPE: none
# Optional, can be combined with Auto Backup Configuration
# PGBACKREST_AUTO_ENABLE: "true"
# PGBACKREST_AUTO_FULL_CRON: "00 00 * * *"
# PGBACKREST_AUTO_DIFF_CRON: "0 */6 * * *"
# PGBACKREST_AUTO_INCR_CRON: "*/15 * * * *"
# PGBACKREST_AUTO_TIMEZONE: "Asia/Jakarta"
volumes:
- ./.data:/usr/local/pgsql/data
- ./.backup:/usr/local/pgsql/backup
- /home/<user>/.ssh/id_ed25519:/home/postgres/.ssh/id_ed25519:ro
- /home/<user>/.ssh/id_ed25519.pub:/home/postgres/.ssh/id_ed25519.pub:ro

Backup to GCS (Google Cloud Storage)

The image also supports backing up to Google Cloud Storage:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
ports:
- "5434:5432"
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_REPO_TYPE: gcs
PGBACKREST_REPO_GCS_BUCKET: my-pgbackrest-bucket
PGBACKREST_REPO_GCS_ENDPOINT: storage.googleapis.com
PGBACKREST_REPO_GCS_KEY: <service-account-key>
# Optional GCS settings
# PGBACKREST_REPO_GCS_ENDPOINT_FLEXIBLE: "true"
# PGBACKREST_REPO_GCS_CA_BUNDLE_FILE: "/path/to/ca-bundle.crt"
# PGBACKREST_REPO_GCS_CA_BUNDLE_PATH: "/path/to/ca-bundle/"
volumes:
- ./.data:/usr/local/pgsql/data
- ./.backup:/usr/local/pgsql/backup

GCS Configuration Options

VariableDescription
PGBACKREST_REPO_GCS_BUCKETGCS bucket name
PGBACKREST_REPO_GCS_ENDPOINTGCS endpoint (default: storage.googleapis.com)
PGBACKREST_REPO_GCS_KEYService account JSON key
PGBACKREST_REPO_GCS_KEY_TYPEKey type (default: service-account)
PGBACKREST_REPO_GCS_USER_PROJECTGCP project ID for requester-pays buckets
PGBACKREST_REPO_GCS_ENDPOINT_FLEXIBLEEnable flexible endpoint matching
PGBACKREST_REPO_GCS_CA_BUNDLE_FILECA bundle file for TLS verification
PGBACKREST_REPO_GCS_CA_BUNDLE_PATHCA bundle directory for TLS verification

Standby Backup via SSH

For environments with SSH access between replicas and the primary, you can configure standby backup to reduce load on the primary. This allows replicas to perform backups directly without impacting the primary's performance.

info

No sidecar container required! The PostgreSQL container includes built-in SSHD that runs automatically on the primary when standby backup is configured. SSH keys are auto-generated and shared via a volume.

Requirements

RequirementDescription
SSH accessPasswordless SSH from replica to primary
Primary pathPGBACKREST_PRIMARY_PATH must point to primary's data directory
Shared SSH volumeReplicas mount the same SSH volume as primary to access keys

Built-in SSHD

The PostgreSQL container automatically runs an SSHD daemon on the primary node when standby backup is configured. This eliminates the need for a separate SSHD sidecar container.

How it works:

  • SSH host keys are generated automatically on first startup
  • SSH user keys (for replica authentication) are generated and added to authorized_keys
  • Replicas mount the same volume (/home/postgres/.ssh) to access the keys
  • SSHD starts automatically at runtime on primary nodes

Volume configuration required:

volumes:
- postgresql_primary_ssh:/home/postgres/.ssh # Shared between primary and replicas

SSH Configuration Environment Variables

VariableDefaultDescription
PGBACKREST_PRIMARY_HOST-Primary hostname (required for standby backup)
PGBACKREST_PRIMARY_PORT5432Primary PostgreSQL port
PGBACKREST_PRIMARY_PATH-Primary data directory path (required for standby backup)
PGBACKREST_PRIMARY_USERpostgresUser for primary connection
PGBACKREST_PRIMARY_SSH_PORT22SSH port for primary
PGBACKREST_PRIMARY_SSH_USERpostgresSSH user for primary
PGBACKREST_PRIMARY_SSH_KEY_FILE/home/postgres/.ssh/id_rsaSSH private key file
PGBACKREST_PRIMARY_SSH_STRICT_HOST_KEY_CHECKINGyesEnable strict host key checking
PGBACKREST_PRIMARY_SSH_KNOWN_HOSTS-Path to known_hosts file

For development/testing, disable strict host key checking:

PGBACKREST_PRIMARY_SSH_STRICT_HOST_KEY_CHECKING: "no"

Backup Standby Modes

ModeValueDescription
Requiredy, yes, 1, on, trueBackup must run from standby; fails if unavailable
PreferredpreferBackup from standby if available, otherwise fallback to primary
Disabledn, no, 0, off, falseBackup from primary only
services:
postgresql-primary:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
ports:
- "5432:5432"
- "2222:22" # SSH port (optional, for external access)
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_PRIMARY_PATH: /usr/local/pgsql/data
PGBACKREST_BACKUP_STANDBY: "prefer"
volumes:
- ./.data:/usr/local/pgsql/data
- ./.backup:/usr/local/pgsql/backup
- postgresql_ssh:/home/postgres/.ssh # Shared SSH volume

postgresql-replica:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
ports:
- "5433:5432"
environment:
REPLICATION_ROLE: replica
PRIMARY_HOST: postgresql-primary
PGBACKREST_ENABLE: "true"
PGBACKREST_PRIMARY_PATH: /usr/local/pgsql/data
PGBACKREST_PRIMARY_HOST: postgresql-primary
PGBACKREST_BACKUP_STANDBY: "y"
volumes:
- ./.data:/usr/local/pgsql/data
- ./.backup:/usr/local/pgsql/backup
- postgresql_ssh:/home/postgres/.ssh # Mount same SSH volume

volumes:
postgresql_ssh:

For a complete working example, see compose.native-ha.backup-standby.yaml.

Kubernetes Limitations

warning

Standby backup (backup-standby=y or prefer) does not work in Kubernetes due to:

  • No SSH between pods - Pods cannot SSH to each other
  • Pod isolation - Each PostgreSQL runs on its own node with no network access to other pods

In K8s environments, always set PGBACKREST_BACKUP_STANDBY: "n" or leave it unset (defaults to primary-only backup).

For Kubernetes, use primary-only backup to S3:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_BACKUP_STANDBY: "n" # Explicitly disable for K8s
PGBACKREST_REPO_TYPE: s3
PGBACKREST_REPO_S3_BUCKET: my-backups
PGBACKREST_REPO_S3_ENDPOINT: s3.amazonaws.com
# ... S3 credentials

Boolean Value Formats

All pgBackRest-related environment variables that accept boolean values accept the following formats (case-insensitive):

ValueDescription
true, 1, yes, on, yTruthy values
false, 0, no, off, nFalsy values

For example, all of the following are equivalent:

environment:
PGBACKREST_ENABLE: "true" # ✓
PGBACKREST_ENABLE: "1" # ✓ also truthy
PGBACKREST_ENABLE: "yes" # ✓ also truthy
PGBACKREST_ENABLE: "on" # ✓ also truthy
PGBACKREST_ENABLE: "y" # ✓ also truthy

PGBACKREST_ENABLE Precedence

PGBACKREST_ENABLE acts as a master switch. When set to false, all related pgBackRest settings are silently ignored even if they are configured:

SettingBehavior when PGBACKREST_ENABLE=false
PGBACKREST_AUTO_ENABLEIgnored - automatic backup scheduling is disabled
PGBACKREST_RESTOREIgnored - restore operations are disabled
PGBACKREST_ARCHIVE_ENABLEIgnored - WAL archiving is disabled

This design prevents accidental backup/restore operations when you have disabled pgBackRest but forgot to unset related variables.

Warning Messages

When contradictions are detected, the container logs warnings (not errors) to help you identify misconfigurations:

WARNING: PGBACKREST_ENABLE is false but PGBACKREST_AUTO_ENABLE is true - ignoring auto backup settings
WARNING: PGBACKREST_ENABLE is false but PGBACKREST_RESTORE is true - ignoring restore settings

Point-in-Time Recovery (PITR)

The container supports comprehensive Point-in-Time Recovery options. Configure restore targets using environment variables:

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
environment:
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_STANZA: default
# PITR Target Options (choose one or more)
PGBACKREST_RESTORE_TARGET_IMMEDIATE: "true" # Stop at immediate consistency point
# PGBACKREST_RESTORE_TARGET_XID: "12345" # Transaction ID
# PGBACKREST_RESTORE_TARGET_LSN: "0/3000000" # Log Sequence Number
# PGBACKREST_RESTORE_TARGET_NAME: "my_restore_point" # Named restore point
# PGBACKREST_RESTORE_TARGET: "2025-01-15 14:30:00+07" # Timestamp target
# PGBACKREST_RESTORE_TARGET_TIMELINE: "latest" # Timeline
# PGBACKREST_RESTORE_TARGET_ACTION: "pause" # Action at target: pause/promote/shutdown
# PGBACKREST_RESTORE_RECOVERY_TARGET_TLI: "1" # Recovery target timeline
# PGBACKREST_RESTORE_RECOVERY_TARGET_ACTION: "promote" # Action at recovery target
# Additional restore options
PGBACKREST_RESTORE_TYPE: "name" # Restore type: name, time, xid, lsn, immediate
PGBACKREST_RESTORE_DELTA: "true" # Use checksum-based delta restore
PGBACKREST_RESTORE_FORCE: "false" # Force restore operation
PGBACKREST_RESTORE_SET: "latest" # Select specific backup set
# PGBACKREST_RESTORE_TABLESPACE_MAP: "old_dir=/new_dir,ts2=/mnt/ts" # Remap tablespaces
volumes:
- ./.data:/usr/local/pgsql/data
- ./.backup:/usr/local/pgsql/backup

PITR Configuration Options

VariableDescription
PGBACKREST_RESTORE_TARGETRecovery target time (timestamp)
PGBACKREST_RESTORE_TARGET_XIDRecovery target transaction ID
PGBACKREST_RESTORE_TARGET_LSNRecovery target LSN (Log Sequence Number)
PGBACKREST_RESTORE_TARGET_NAMENamed restore point to recover to
PGBACKREST_RESTORE_TARGET_IMMEDIATEStop at immediate consistency point
PGBACKREST_RESTORE_TARGET_TIMELINETimeline to recover to (e.g., latest)
PGBACKREST_RESTORE_TARGET_ACTIONAction at target: pause, promote, shutdown
PGBACKREST_RESTORE_RECOVERY_TARGET_TLIRecovery target timeline ID
PGBACKREST_RESTORE_RECOVERY_TARGET_ACTIONRecovery target action: pause, promote, shutdown
PGBACKREST_RESTORE_TYPERestore type: name, time, xid, lsn, immediate
PGBACKREST_RESTORE_DELTAUse checksum-based delta restore (default: true)
PGBACKREST_RESTORE_FORCEForce restore, bypassing safety checks
PGBACKREST_RESTORE_SETSelect specific backup set (e.g., latest)
PGBACKREST_RESTORE_TABLESPACE_MAPRemap tablespaces during restore (format: old_dir=/new_dir)

Example: Restore to Named Restore Point

services:
postgresql:
environment:
PGBACKREST_ENABLE: "true"
PGBACKREST_RESTORE_TARGET_NAME: "before_major_change"
PGBACKREST_RESTORE_TYPE: "name"

Example: Restore to Specific Timestamp

services:
postgresql:
environment:
PGBACKREST_ENABLE: "true"
PGBACKREST_RESTORE_TARGET: "2025-01-15 14:30:00+07"
PGBACKREST_RESTORE_TYPE: "time"
PGBACKREST_RESTORE_TARGET_ACTION: "promote"

Example: Immediate Recovery with Tablespace Remapping

services:
postgresql:
environment:
PGBACKREST_ENABLE: "true"
PGBACKREST_RESTORE_TARGET_IMMEDIATE: "true"
PGBACKREST_RESTORE_TABLESPACE_MAP: "/old/ts1=/mnt/storage/ts1,/old/ts2=/mnt/storage/ts2"

Patroni Integration

When using Patroni for HA management, pgBackRest automatically integrates via Patroni callbacks. This ensures pgBackRest configuration is updated when nodes change roles during failover or switchover.

How It Works

EventAction
Replica promoted to primaryRemove pg2-host settings, set backup-standby=n
Primary demoted to replicaAdd pg2-host settings (if PGBACKREST_PRIMARY_PATH set)
Backup completesLog status to container logs
Restore completesRegenerate pgBackRest config for current role

Environment Variables

VariableDefaultDescription
PATRONI_PGBACKREST_CALLBACKStrueEnable/disable Patroni callbacks

Example Compose Configuration

services:
postgresql:
image: ghcr.io/supanadit/containers/postgresql:17.6-r0.0.19
environment:
HA_MODE: patroni
PATRONI_NAME: postgres-${HOSTNAME}
PATRONI_SCOPE: postgres-cluster
ETCD_HOSTS: etcd:2379
POSTGRES_PASSWORD: secret
PGBACKREST_ENABLE: "true"
PGBACKREST_STANZA: default
PGBACKREST_REPO_TYPE: s3
PGBACKREST_REPO_S3_BUCKET: pgbackrest
PGBACKREST_REPO_S3_ENDPOINT: minio:9000
PGBACKREST_REPO_S3_KEY: superadmin
PGBACKREST_REPO_S3_KEY_SECRET: supersecretpassword
PGBACKREST_AUTO_ENABLE: "true"
PGBACKREST_AUTO_FULL_CRON: "00 02 * * *"
PATRONI_PGBACKREST_CALLBACKS: "true" # Default, but explicit
volumes:
- postgresql_data:/usr/local/pgsql/data
- pgbackrest_backup:/usr/local/pgsql/backup

Limitations

  • Callbacks require Patroni HA mode (HA_MODE: patroni)
  • Standby backup (pg2-host) requires SSH access to primary
  • Not compatible with Kubernetes (no SSH between pods)
  • For Kubernetes, use PGBACKREST_BACKUP_STANDBY: "n" with S3 backup

Environment Variables Reference

General Configuration

VariableDefaultDescription
PGBACKREST_ENABLEfalseEnable pgBackRest backup/restore
PGBACKREST_STANZAdefaultpgBackRest stanza name
PGBACKREST_PASSWORD-PostgreSQL password for pgBackRest connection

Automatic Backup

VariableDefaultDescription
PGBACKREST_AUTO_ENABLEfalseEnable automatic backup scheduling
PGBACKREST_AUTO_FULL_CRON0 2 * * *Full backup cron schedule
PGBACKREST_AUTO_DIFF_CRON20 2,8,14,20 * * *Differential backup cron schedule
PGBACKREST_AUTO_INCR_CRON*/15 * * * *Incremental backup cron schedule
PGBACKREST_AUTO_TIMEZONEUTCTimezone for cron schedules
PGBACKREST_AUTO_PRIMARY_ONLYtrueOnly run backups on primary
PGBACKREST_AUTO_FIRST_INCR_DELAY120Delay before first incremental backup (seconds)

Backup Performance & Verification

VariableDefaultDescription
PGBACKREST_BACKUP_START_FASTfalseForce checkpoint before backup
PGBACKREST_BACKUP_STOP_AUTOfalseStop PostgreSQL after backup
PGBACKREST_BACKUP_VERIFYtrueVerify backup after creation
PGBACKREST_BACKUP_CHECKSUM_PAGEfalseValidate data page checksums during backup
PGBACKREST_BACKUP_ARCHIVE_CHECKtrueCheck WAL segments in archive
PGBACKREST_BACKUP_ARCHIVE_COPYfalseCopy WAL segments for backup consistency
PGBACKREST_BACKUP_ARCHIVE_MISSING_RETRYtrueRetry WAL segments previously reported missing
PGBACKREST_BACKUP_EXPIRE_AUTOfalseAuto-run expire after backup
PGBACKREST_BACKUP_RESUMEtrueAllow resuming failed backup
PGBACKREST_BACKUP_EXCLUDE-Exclude paths from backup (comma-separated)
PGBACKREST_BACKUP_ANNOTATION-Backup annotations (format: key=value,key2=value2)
PGBACKREST_PROCESS_MAX-Parallel processes for backup/restore
PGBACKREST_BACKUP_STANDBY-Backup from standby: y, prefer, n

Storage & Retention

VariableDefaultDescription
PGBACKREST_REPO_TYPEposixRepository type: posix, s3, gcs, sftp, azure
PGBACKREST_REPO_PATH-Repository path override
PGBACKREST_REPO_RETENTION_FULL2Full backup retention count
PGBACKREST_REPO_RETENTION_DIFF6Differential backup retention count
PGBACKREST_REPO_RETENTION_FULL_TYPE-Retention type: full or backup
PGBACKREST_REPO_RETENTION_ARCHIVE-WAL archive retention count
PGBACKREST_REPO_RETENTION_ARCHIVE_TYPE-WAL retention type: full, diff, incr
PGBACKREST_REPO_RETENTION_HISTORY-Backup history manifest retention days (0 = unexpired only)
PGBACKREST_REPO_HARDLINKfalseCreate hardlinks for local backups
PGBACKREST_REPO_SYMLINKfalseCreate symlinks in repository
PGBACKREST_REPO_CIPHER_TYPE-Encryption cipher: none, aes-256-cbc
PGBACKREST_REPO_CIPHER_PASS-Encryption passphrase
PGBACKREST_ARCHIVE_ASYNCfalseEnable async WAL archiving
PGBACKREST_SPARSE_TABLEfalseEnable sparse table support
PGBACKREST_REPO_COMPRESSIONgzipCompression: gzip, lz4, zstd
PGBACKREST_COMPRESS_LEVEL-Compression level (0-9 for gzip, 0-19 for zstd)
PGBACKREST_COMPRESS_LEVEL_NETWORK-Network compression level

Performance & Tuning

VariableDefaultDescription
PGBACKREST_BUFFER_SIZE-Buffer size for I/O (16KiB-16MiB)
PGBACKREST_IO_TIMEOUT-I/O timeout
PGBACKREST_DB_TIMEOUT-Database query timeout
PGBACKREST_PROTOCOL_TIMEOUT-Protocol timeout
PGBACKREST_ARCHIVE_GET_QUEUE_MAX-Max size of archive-get queue
PGBACKREST_ARCHIVE_PUSH_QUEUE_MAX-Max size of archive-push queue
PGBACKREST_ARCHIVE_TIMEOUT-Archive command timeout
PGBACKREST_TCP_KEEP_ALIVE_COUNT-TCP keep-alive count
PGBACKREST_TCP_KEEP_ALIVE_IDLE-TCP keep-alive idle time
PGBACKREST_TCP_KEEP_ALIVE_INTERVAL-TCP keep-alive interval
PGBACKREST_SCK_KEEP_ALIVEfalseEnable socket keep-alive
PGBACKREST_NEUTRAL_UMASKfalseUse neutral umask for files
PGBACKREST_MANIFEST_SAVE_THRESHOLD-Manifest save threshold

S3 Configuration

VariableDescription
PGBACKREST_REPO_S3_BUCKETS3 bucket name
PGBACKREST_REPO_S3_ENDPOINTS3 endpoint URL
PGBACKREST_REPO_S3_REGIONS3 region
PGBACKREST_REPO_S3_KEYS3 access key
PGBACKREST_REPO_S3_KEY_SECRETS3 secret key
PGBACKREST_REPO_S3_BUCKET_REGIONExplicit bucket region
PGBACKREST_REPO_S3_ENDPOINT_FLEXIBLEFlexible endpoint matching
PGBACKREST_REPO_S3_URI_STYLEURI style: path or host
PGBACKREST_REPO_S3_PORTS3 port
PGBACKREST_REPO_S3_VERIFY_TLSVerify TLS certificates
PGBACKREST_REPO_S3_CA_FILECA bundle file
PGBACKREST_REPO_S3_CA_PATHCA bundle path
PGBACKREST_REPO_S3_STORAGE_CLASSStorage class
PGBACKREST_REPO_S3_TOKENSTS token
PGBACKREST_REPO_S3_KMS_KEY_IDAWS KMS key ID for SSE encryption
PGBACKREST_REPO_S3_SSE_CUSTOMER_KEYSSE-C customer key
PGBACKREST_REPO_S3_ROLEIAM role for temporary credentials
PGBACKREST_REPO_S3_KEY_TYPEKey type: shared, auto, web-id
PGBACKREST_REPO_S3_REQUESTER_PAYSEnable S3 requester pays

Repository Storage Configuration (Unified)

VariableDescription
PGBACKREST_REPO_STORAGE_HOSTCustom storage host
PGBACKREST_REPO_STORAGE_PORTCustom storage port
PGBACKREST_REPO_STORAGE_CA_FILECA bundle file
PGBACKREST_REPO_STORAGE_CA_PATHCA bundle path
PGBACKREST_REPO_STORAGE_VERIFY_TLSVerify TLS certificates
PGBACKREST_REPO_STORAGE_UPLOAD_CHUNK_SIZEUpload chunk size
PGBACKREST_REPO_STORAGE_TAGStorage tags (comma-separated)

GCS Configuration

VariableDescription
PGBACKREST_REPO_GCS_BUCKETGCS bucket name
PGBACKREST_REPO_GCS_ENDPOINTGCS endpoint
PGBACKREST_REPO_GCS_KEYService account key
PGBACKREST_REPO_GCS_KEY_TYPEKey type
PGBACKREST_REPO_GCS_USER_PROJECTGCP project for requester-pays
PGBACKREST_REPO_GCS_ENDPOINT_FLEXIBLEFlexible endpoint matching
PGBACKREST_REPO_GCS_CA_BUNDLE_FILECA bundle file
PGBACKREST_REPO_GCS_CA_BUNDLE_PATHCA bundle path

SFTP Configuration

VariableDescription
PGBACKREST_REPO_SFTP_HOSTSFTP host
PGBACKREST_REPO_SFTP_HOST_PORTSFTP port
PGBACKREST_REPO_SFTP_HOST_USERSFTP user
PGBACKREST_REPO_SFTP_PRIVATE_KEY_FILEPrivate key path
PGBACKREST_REPO_SFTP_PUBLIC_KEY_FILEPublic key path
PGBACKREST_REPO_SFTP_HOST_KEY_HASH_TYPEHost key hash type
PGBACKREST_REPO_SFTP_HOST_KEY_CHECK_TYPEHost key check type
PGBACKREST_REPO_SFTP_KNOWN_HOSTSKnown hosts file
PGBACKREST_REPO_SFTP_PRIVATE_KEY_PASSPHRASEKey passphrase

Repository Host Configuration (Remote Repository)

VariableDescription
PGBACKREST_REPO_HOSTRemote repository host
PGBACKREST_REPO_HOST_PORTRemote repository port
PGBACKREST_REPO_HOST_USERRemote repository user
PGBACKREST_REPO_HOST_TYPEProtocol type: ssh, tls
PGBACKREST_REPO_HOST_KEY_FILESSH private key file
PGBACKREST_REPO_HOST_CA_FILECA certificate file
PGBACKREST_REPO_HOST_CA_PATHCA certificate path
PGBACKREST_REPO_HOST_CERT_FILEClient certificate file
PGBACKREST_REPO_HOST_CONFIGConfig file on repository host
PGBACKREST_REPO_HOST_CONFIG_PATHConfig path on repository host

PostgreSQL Stanza Configuration (pg1-host)

VariableDescription
PGBACKREST_PG_DATABASEDatabase name for connection (default: postgres)
PGBACKREST_PG_HOSTRemote PostgreSQL host
PGBACKREST_PG_HOST_PORTRemote PostgreSQL port
PGBACKREST_PG_HOST_USERRemote PostgreSQL user
PGBACKREST_PG_HOST_TYPEProtocol type: ssh, tls
PGBACKREST_PG_HOST_KEY_FILESSH key for PostgreSQL host
PGBACKREST_PG_HOST_CA_FILECA file for PostgreSQL host
PGBACKREST_PG_HOST_CA_PATHCA path for PostgreSQL host
PGBACKREST_PG_HOST_CERT_FILEClient cert for PostgreSQL host
PGBACKREST_PG_HOST_CONFIGConfig file on PostgreSQL host
PGBACKREST_PG_HOST_CONFIG_PATHConfig include path on PostgreSQL host
PGBACKREST_PG_HOST_CMDpgBackRest command path on remote host

Standby Backup (SSH)

VariableDefaultDescription
PGBACKREST_PRIMARY_HOST-Primary hostname
PGBACKREST_PRIMARY_PORT5432Primary PostgreSQL port
PGBACKREST_PRIMARY_PATH-Primary data directory
PGBACKREST_PRIMARY_USERpostgresPrimary user
PGBACKREST_PRIMARY_SSH_PORT22Primary SSH port
PGBACKREST_PRIMARY_SSH_USERpostgresPrimary SSH user
PGBACKREST_PRIMARY_SSH_KEY_FILE/home/postgres/.ssh/id_rsaSSH key file
PGBACKREST_PRIMARY_SSH_STRICT_HOST_KEY_CHECKINGyesStrict host key checking
PGBACKREST_PRIMARY_HOST_CA_FILE-CA file for primary connection
PGBACKREST_PRIMARY_HOST_CA_PATH-CA path for primary connection
PGBACKREST_PRIMARY_HOST_CERT_FILE-Client cert for primary connection
PGBACKREST_PRIMARY_HOST_CONFIG-Config file on primary host
PGBACKREST_PRIMARY_HOST_CONFIG_PATH-Config path on primary host

Point-in-Time Recovery

VariableDescription
PGBACKREST_RESTORE_TYPERestore type: name, time, xid, lsn, immediate
PGBACKREST_RESTORE_TARGETRecovery target timestamp
PGBACKREST_RESTORE_TARGET_XIDRecovery target transaction ID
PGBACKREST_RESTORE_TARGET_LSNRecovery target LSN
PGBACKREST_RESTORE_TARGET_NAMENamed restore point
PGBACKREST_RESTORE_TARGET_IMMEDIATEStop at immediate consistency
PGBACKREST_RESTORE_TARGET_TIMELINETarget timeline
PGBACKREST_RESTORE_TARGET_ACTIONAction at target: pause, promote, shutdown
PGBACKREST_RESTORE_RECOVERY_TARGET_TLIRecovery target timeline ID
PGBACKREST_RESTORE_RECOVERY_TARGET_ACTIONRecovery target action
PGBACKREST_RESTORE_ARCHIVE_MODEArchive mode on restore: off, on, always
PGBACKREST_RESTORE_LINK_ALLRestore all symlinks
PGBACKREST_RESTORE_LINK_MAPModify symlink destinations (format: old=/new)
PGBACKREST_RESTORE_DB_INCLUDEInclude only specified databases (comma-separated)
PGBACKREST_RESTORE_DB_EXCLUDEExclude databases from restore (comma-separated)
PGBACKREST_RESTORE_RECOVERY_OPTIONSet postgresql.auto.conf options (format: key=value)
PGBACKREST_RESTORE_DELTAUse delta restore (checksum-based)
PGBACKREST_RESTORE_FORCEForce restore operation
PGBACKREST_RESTORE_SETSelect specific backup set
PGBACKREST_RESTORE_TABLESPACE_MAPTablespace remapping (format: old=/new)
PGBACKREST_RESTORE_TABLESPACE_MAP_ALLRestore all tablespaces to directory