TDE-enabled clusters support transparent backups and restores using pgBackRest, and you do not need to perform any additional steps. For more information, see Create a TDE-enabled cluster.
For more information about pgBackRest, see its user guide.
Before you begin
Before configuring AlloyDB Omni to work with pgBackRest, complete the following prerequisites:
- Install and run AlloyDB Omni on a server that you control.
Basic configuration with local backups
The steps in this section guide you through a basic setup of pgBackRest. Basic configurations don't enable backups on a schedule. For more information, see Set up scheduled backups.
Because pgBackRest is a flexible third-party product compatible with AlloyDB Omni, you can modify any of these steps as appropriate for your own needs and preferences.
Create a backup directory
For organization purposes, we strongly recommend that you create a separate directory for pgBackRest backups. To set up a new directory, complete the following steps:
If AlloyDB Omni is running, stop it.
sudo systemctl stop alloydbomni18
Create a backup directory.
sudo mkdir -p BACKUP_DIR
Replace the following variable:
BACKUP_DIR: Host directory that your backups will be stored in.
Make the backups directory readable by
postgres.sudo chown -R postgres:postgres BACKUP_DIR
Replace the following variable:
BACKUP_DIR: Host directory that your backups will be stored in.
Configure local backups
pgBackRest creates subdirectories for each backup taken and includes a plain-text manifest file.
pgBackRest uses the term stanza to refer to the configuration for a PostgreSQL database cluster. The stanza name is arbitrary and doesn't need to match the host server, PostgreSQL cluster, or database name. The pgBackRest documentation suggests naming the stanza after the cluster's function.
The repository is where backups are written. pgBackRest supports writing to more
than one repository in a given stanza. Most configuration parameters related to
repositories are indexed with a numeric value. For example, repo1-. Parameters
related to PostgreSQL clusters are also, independently, indexed. For example,
pg1-.
pgBackRest leverages a configuration file, called pgbackrest.conf, to hold
global and stanza-specific parameters.
To build and initialize a configuration file for backing up your
AlloyDB Omni cluster, create the pgbackrest.conf file in the
host-side backups directory you created in
Mount a backup volume to your container or Create a backup directory.
[global]
# Paths (all mandatory):
repo1-path=BACKUP_DIR
spool-path=BACKUP_DIR/spool
lock-path=BACKUP_DIR
# Retention details:
repo1-retention-full=3
repo1-retention-full-type=count
repo1-retention-diff=16
# Force a checkpoint to start backup immediately:
start-fast=y
# Logging parameters:
log-path=BACKUP_DIR
log-level-console=info
log-level-file=info
# Recommended ZSTD compression:
compress-type=zst
# Other performance parameters:
archive-async=y
archive-push-queue-max=1024MB
archive-get-queue-max=256MB
archive-missing-retry=y
[global:archive-push]
process-max=2
[global:archive-get]
process-max=2
[omni]
pg1-user=postgres
pg1-socket-path=/tmp
pg1-path=DATA_DIR
Some parameters are mandatory, but others can be adjusted to meet your specific requirements if needed, such as the following:
repo1-path: Directory location where the backups are written to. We recommend a location visible to both the host server and the container.log-path: Directory location where the log files are written to. If you want to write the log files to a separate location, not mixed with the backups themselves, adjust this parameter.repo1-retention-full: Number of full backups to retain.repo1-retention-full-type: Whether the retention is measured by count or time period (days).repo1-retention-diff: Number of differential backups to retain.
Other non-critical, but recommended, parameter settings that are compatible with AlloyDB Omni in the configuration file include the following:
log-level-console: Level of logging written to the screen (STDOUT) when running pgBackup commands. You can adjust this to meet your needs in the configuration file, or override this value with the--log-level-consolecommand line argument. The default iswarn.start-fast: Forces a checkpoint to start the backups quickly. The default isn.archive-async: Push WAL segment files asynchronously for performance. The default isn.process-max: Maximum number of processes to use for compression and transfer. This is typically set tomax_cpu/4on a primary ormax_cpu/2on a standby cluster. The default is1.compress-type: Compression algorithm to use. The default isgz.
Many other pgBackRest configuration parameters exist and can be adjusted. This documentation covers only the parameters mandatory for the default AlloyDB Omni configuration and some recommended parameter settings. For the full list of configuration parameters, refer to the pgBackRest Configuration Reference online documentation.
After configuring pgBackRest, the target repositories where backups are written to must be initialized by creating the stanza, which uses the parameters as set in the configuration file.
To configure your database for backups, complete the following steps:
Create the stanza using the
stanza-createcommand.sudo -u postgres pgbackrest \ --config-path=/var/lib/BACKUP_DIR \ --stanza=omni stanza-create
Configure your database for backups.
/usr/lib/postgresql/18/bin/psql -h localhost -U postgres \ -c "ALTER SYSTEM SET archive_command='pgbackrest --config-path=BACKUP_DIR --stanza=omni archive-push %p';" \ -c "ALTER SYSTEM SET archive_mode=on;" \ -c "ALTER SYSTEM SET max_wal_senders=10;" \ -c "ALTER SYSTEM SET wal_level=replica;"
Replace the following variable:
BACKUP_DIR: Host directory that your backups will be stored in.
Restart AlloyDB Omni.
sudo systemctl restart 18
Validate the backup configuration.
/usr/lib/postgresql/18/bin/psql -h localhost -U postgres \ -c "SELECT name, setting FROM pg_catalog.pg_settings WHERE name IN ('archive_command', 'archive_mode', 'max_wal_senders', 'wal_level') ORDER BY name"Perform a pgBackRest check.
sudo -u postgres pgbackrest \ --config-path=BACKUP_DIR \ --stanza=omni \ check