Restore an AlloyDB Omni cluster using Barman

This page shows you how to restore an AlloyDB Omni cluster using a backup created with Barman, an open-source database backup server.

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

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

Before you begin

Before restoring your AlloyDB Omni data, you need the following:

  • A target database server, running the same major version of AlloyDB Omni as the source database server. For more information about installing AlloyDB Omni, see Install AlloyDB Omni.

    The target server can be the same machine as the source server.

  • The rsync utility, installed on the target server.

  • A Barman backup server, with at least one valid Barman backup of the source AlloyDB Omni database on it.

  • SSH connectivity between the Barman backup server and the target server.

  • SSH keys set up to allow the barman user on the Barman server to authenticate with the target server as its postgres user without a password.

  • Enough free disk space on the target server to hold the restored database.

Recover using a specific backup

  1. On the target server, stop AlloyDB Omni.

    docker stop OMNI_CONTAINER_NAME

    Replace OMNI_CONTAINER_NAME with the name that you assigned to the AlloyDB Omni container when you installed it.

  2. On the Barman server, choose a backup to restore from. To see available backups, run the barman list-backups command. To see details about a particular backup, run the barman show-backup command.

  3. To recover the chosen backup into the target AlloyDB Omni server, run the barman recover command.

    When running the command, include the following:

    The following command demonstrates an example use of barman recover with AlloyDB Omni:

    barman recover --remote-ssh-command "ssh postgres@TARGET_IP" TARGET_LABEL BACKUP_ID DATA_PATH

    Replace the following:

    • TARGET_IP: the IP address of the target server.

    • TARGET_LABEL: the label that you assigned to the server in Barman's configuration file.

    • BACKUP_ID: the ID of the backup to restore from, identified in a previous step—for example, 20230810T210200.

    • DATA_PATH: the path to the data subdirectory of the target server's data directory—for example, /home/your-username/alloydb-data/data.

  4. On the AlloyDB Omni target database server, start the service:

docker start OMNI_CONTAINER_NAME

After the service restarts, connect to your AlloyDB Omni server. You should see your restored databases and data.

Recover to a specific point in time

To perform a point-in-time recovery, follow the same steps listed in the previous section, with one modification. When you run the barman recover command, you must also specify one of the Barman point-in-time recovery options.

The following command demonstrates an example use of barman recover with AlloyDB Omni with a point-in-time recovery option:

barman recover --remote-ssh-command "ssh postgres@TARGET_IP" TARGET_LABEL BACKUP_ID --target-time="RESTORE_TIMESTAMP" DATA_PATH

Replace the following:

  • TARGET_IP: the IP address of the target server.

  • TARGET_LABEL: the label that you assigned to the server in Barman's configuration file.

  • BACKUP_ID: the ID of the backup to restore from, identified in a previous step—for example, 20230810T210200.

  • TARGET_TIMESTAMP: the time to restore to, in any PostgreSQL timestamp format that specifies both a date and a time—for example, 2024-02-06 00:00:00.

  • DATA_PATH: the path to the data subdirectory of the target server's data directory—for example, /home/your-username/alloydb-data/data.