Restore from a pgBackRest-based backup for AlloyDB Omni on Linux

Select a documentation version:

This page shows you how to restore an AlloyDB Omni cluster using a backup created with pgBackRest, the open-source backup solution included with the AlloyDB Omni.

Because AlloyDB Omni is compatible with PostgreSQL, the data-restoration commands and techniques described by the pgBackRest manual apply to AlloyDB Omni as well. This page demonstrates a selection of common recovery tasks, with examples of relevant commands.

TDE-enabled clusters also support backup and restores using pgBackRest. For more information, see Create a TDE-enabled cluster.

For more information about configuring pgBackRest to work with AlloyDB Omni, see Set up pgBackRest for AlloyDB Omni.

Before you begin

Before restoring an AlloyDB Omni cluster, ensure that you have the following:

  • Run sudo dnf install pgbackrest to install pgBackRest.

  • Set up and configure pgBackRest for your AlloyDB Omni instance.

  • Sufficient disk space on destination file system to store the restored AlloyDB Omni database cluster.

  • Same major version of AlloyDB Omni used for the restoration database instance as the original source database instance.

    To check your version of PostgreSQL, run the following command:

    /usr/lib/postgresql/18/bin/psql -h localhost -U postgres -c "SELECT version();"
    

    To check your version of pgBackRest, run the following command:

    pgbackrest version
    

    If your target database instance has a different version of PostgreSQL, pgBackRest, or both, then you need to create a new target database instance with a matching version. If this is not possible, then you need to use an alternative method, such as the PostgreSQL included pg_dump or pg_dumpall utilities to copy your databases across versions.

Stop AlloyDB Omni

To simulate your AlloyDB Omni database cluster not being available, stop the service.

sudo systemctl stop 18

Remove your data directory

To clear your AlloyDB Omni database cluster, remove the data directory.

sudo rm -rf DATA_DIR/*

Replace the following variable:

  • DATA_DIR: Host directory path that your data is stored in.

Validate that your backups are visible

sudo -u postgres pgbackrest \
--config-path=/var/lib/BACKUP_DIR \
--stanza=STANZA_NAME \
info

Replace the following variables:

  • STANZA_NAME: Name of the stanza you created. For example, my-stanza.
  • Restore your backup

    sudo -u postgres pgbackrest \
    --stanza=STANZA_NAME \
    restore
    

    Replace the following variables:

    * STANZA_NAME: Name of the stanza you created. For example, my-stanza.

    Start AlloyDB Omni

    Start the AlloyDB Omni service.

    sudo systemctl start 18
    

    Validate that AlloyDB Omni started

    sudo systemctl status 18
    

    Other options

    The pgBackRest restore command is very flexible, with an array of options and features that you can control through passing in different command-line options. For a complete guide to performing restores, see Restore.