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 rsyncutility, 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 barmanuser on the Barman server to authenticate with the target server as itspostgresuser without a password.
-  Enough free disk space on the target server to hold the restored database. 
Recover using a specific backup
-  On the target server, stop AlloyDB Omni. Dockerdocker stop CONTAINER_NAMEReplace CONTAINER_NAMEwith the name that you assigned to the AlloyDB Omni container when you installed it—for example,my-omni.Podmanpodman stop CONTAINER_NAMEReplace CONTAINER_NAMEwith the name that you assigned to the AlloyDB Omni container when you installed it—for example,my-omni.
-  On the Barman server, choose a backup to restore from. To see available backups, run the barman list-backupscommand . To see details about a particular backup, run thebarman show-backupcommand .
-  To recover the chosen backup into the target AlloyDB Omni server, run the barman recovercommand .When running the command, include the following: - Use the remote recovery option .
- Specify the target server's data directory as the destination directory.
 The following command demonstrates an example use of barman recoverwith AlloyDB Omni:barman recover --remote-ssh-command "ssh postgres@ TARGET_IP " TARGET_LABEL BACKUP_ID DATA_PATHReplace 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 thedatasubdirectory of the target server's data directory—for example,/home/your-username/alloydb-data/data.
 
-  On the AlloyDB Omni target database server, start the service: Dockerdocker start CONTAINER_NAMEPodmanpodman start 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 PostgreSQLtimestampformat that specifies both a date and a time—for example,2024-02-06 00:00:00.
-  DATA_PATH: the path to thedatasubdirectory of the target server's data directory—for example,/home/your-username/alloydb-data/data.

