The following workflow explains the steps used to clone:
Create and apply theDBClustermanifest file on the target database cluster with thelivenessProbeparameter disabled.
Create and configure thepgbackrest.conffile to access the Cloud Storage backup.
UsepgBackRestcommands to verify you can access source backups.
UsepgBackRestcommands to restore the backup to the target database cluster.
Before you begin
Make sure you have access to the full path of the Cloud Storage bucket
where your source database cluster backup is stored. This is the same path you
used when you created theBackupPlanresource for your source database
cluster.
Create a target AlloyDB Omni database cluster.
For more information about installing AlloyDB Omni on Kubernetes, seeCreate a database cluster.
Ensure you are logged in to the database as thepostgresuser.
Create a database cluster in a target database cluster
Create a database cluster by temporarily disabling thelivenessProbeparameter
while the restore process completes.
DB_CLUSTER_NAME: the name of this database cluster—for
example,my-db-cluster.
ENCODED_PASSWORD: the database login password for the
defaultpostgresuser role, encoded as a base64 string—for example,Q2hhbmdlTWUxMjM=forChangeMe123.
CPU_COUNT: the number of CPUs available to each
database instance in this database cluster.
MEMORY_SIZE: the amount of memory per database instance
of this database cluster. We recommend setting this to 8 gigabytes per
CPU. For example, if you setcputo2earlier in this manifest, then
we recommend settingmemoryto16Gi.
DISK_SIZE: the disk size per database instance—for
example,10Gi.
Apply the manifest file:
kubectlapply-fDBCLUSTER_FILENAME
Replace the following:
DBCLUSTER_FILENAME: the name of theDBClustermanifest
file created in the previous step.
Use thekubectl describecommand to verify that the database cluster resource
is in theREADYstatus.
Configure thepgBackRestfile
Configure thepgBackRestfile to enable the target database cluster to access
the Cloud Storage bucket where source backups reside.
In your target database cluster, find the database cluster pod details:
GCS_SOURCE_BACKUP_BUCKET_NAME: the name of the
Cloud Storage
bucket that you created when creating theBackupPlanresource manifest
file for the source database cluster. This is not the full URL to
the bucket; don't prefix the bucket name withgs://.
GCS_SOURCE_BACKUP_BUCKET_PATH: the path of the
directory that the
AlloyDB Omni operator writes backups into, within the
Cloud Storage bucket for the source database cluster. The path
must be absolute, beginning with/.
The timestamps in the response are used either to restore the full backup or to restore
from a point in time from the recovery window.
Restore the backup in the target database cluster
After you identify the backup or a point in time you want to restore to, runpgBackRestcommands in your target database cluster. For more information
about these commands, seeRestore
Command.
The following are some samplepgBackRestrestore commands:
After the restore command completes successfully, you can start thepostgresprocess.
supervisorctl.parstartpostgres
After thepostgresprocess starts, you can connect to the primary instance and
run queries to verify that the data is restored from the backup. For more
information, seeConnect to AlloyDB Omni running on
Kubernetes.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-05 UTC."],[[["\u003cp\u003eThis guide demonstrates how to clone an AlloyDB Omni database cluster in Kubernetes by restoring from a Cloud Storage backup of the source cluster.\u003c/p\u003e\n"],["\u003cp\u003eThe process begins by creating a \u003ccode\u003eDBCluster\u003c/code\u003e manifest on the target cluster with the \u003ccode\u003elivenessProbe\u003c/code\u003e temporarily disabled to allow the restore to complete.\u003c/p\u003e\n"],["\u003cp\u003eConfiguration of the \u003ccode\u003epgBackRest.conf\u003c/code\u003e file is required, ensuring it correctly references the Cloud Storage bucket where the source database backups are stored.\u003c/p\u003e\n"],["\u003cp\u003eVerification of source backups in the target database cluster is achieved using \u003ccode\u003epgBackRest\u003c/code\u003e commands before proceeding with the restore.\u003c/p\u003e\n"],["\u003cp\u003eThe restore process is then completed using specific \u003ccode\u003epgBackRest\u003c/code\u003e commands to restore either from a specific backup set or to a designated point in time.\u003c/p\u003e\n"]]],[],null,["# Clone a database cluster in Kubernetes using a Cloud Storage backup\n\nSelect a documentation version: 16.3.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/kubernetes-dr-backup-k8-gcs)\n- [16.8.0](/alloydb/omni/16.8.0/docs/kubernetes-dr-backup-k8-gcs)\n- [16.3.0](/alloydb/omni/16.3.0/docs/kubernetes-dr-backup-k8-gcs)\n- [15.12.0](/alloydb/omni/15.12.0/docs/kubernetes-dr-backup-k8-gcs)\n- [15.7.1](/alloydb/omni/15.7.1/docs/kubernetes-dr-backup-k8-gcs)\n- [15.7.0](/alloydb/omni/15.7.0/docs/kubernetes-dr-backup-k8-gcs)\n- [15.5.5](/alloydb/omni/15.5.5/docs/kubernetes-dr-backup-k8-gcs)\n- [15.5.4](/alloydb/omni/15.5.4/docs/kubernetes-dr-backup-k8-gcs)\n- [15.5.2](/alloydb/omni/15.5.2/docs/kubernetes-dr-backup-k8-gcs)\n\n\u003cbr /\u003e\n\nThis page shows you how to clone a database cluster in Kubernetes using a Cloud Storage backup of an AlloyDB Omni database cluster.\n\n\u003cbr /\u003e\n\nThe following workflow explains the steps used to clone:\n\n1. Create and apply the `DBCluster` manifest file on the target database cluster with the `livenessProbe` parameter disabled.\n2. Create and configure the `pgbackrest.conf` file to access the Cloud Storage backup.\n3. Use `pgBackRest` commands to verify you can access source backups.\n4. Use `pgBackRest` commands to restore the backup to the target database cluster.\n\nBefore you begin\n----------------\n\n- Make sure you have access to the full path of the Cloud Storage bucket where your source database cluster backup is stored. This is the same path you used when you created the [`BackupPlan`](/alloydb/omni/16.3.0/docs/backup-kubernetes#remote) resource for your source database cluster.\n- Create a target AlloyDB Omni database cluster. For more information about installing AlloyDB Omni on Kubernetes, see [Create a database cluster](/alloydb/omni/16.3.0/docs/deploy-kubernetes#create).\n- Ensure you are logged in to the database as the `postgres` user.\n\nCreate a database cluster in a target database cluster\n------------------------------------------------------\n\nCreate a database cluster by temporarily disabling the `livenessProbe` parameter\nwhile the restore process completes.\n\n1. Create the `DBCluster` resource manifest file:\n\n apiVersion: v1\n kind: Secret\n metadata:\n name: db-pw-\u003cvar translate=\"no\"\u003eDB_CLUSTER_NAME\u003c/var\u003e\n type: Opaque\n data:\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nt\"\u003eDB_CLUSTER_NAME\u003c/span\u003e\u003c/var\u003e: \"\u003cvar translate=\"no\"\u003eENCODED_PASSWORD\u003c/var\u003e\"\n ---\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: DBCluster\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDB_CLUSTER_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n primarySpec:\n availabilityOptions:\n livenessProbe: \"Disabled\"\n adminUser:\n passwordRef:\n name: db-pw-\u003cvar translate=\"no\"\u003eDB_CLUSTER_NAME\u003c/var\u003e\n resources:\n cpu: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCPU_COUNT\u003c/span\u003e\u003c/var\u003e\n memory: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eMEMORY_SIZE\u003c/span\u003e\u003c/var\u003e\n disks:\n - name: DataDisk\n size: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDISK_SIZE\u003c/span\u003e\u003c/var\u003e\n storageClass: standard\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDB_CLUSTER_NAME\u003c/var\u003e: the name of this database cluster---for\n example, `my-db-cluster`.\n\n - \u003cvar translate=\"no\"\u003eENCODED_PASSWORD\u003c/var\u003e: the database login password for the\n default `postgres` user role, encoded as a base64 string---for example,\n `Q2hhbmdlTWUxMjM=` for `ChangeMe123`.\n\n - \u003cvar translate=\"no\"\u003eCPU_COUNT\u003c/var\u003e: the number of CPUs available to each\n database instance in this database cluster.\n\n - \u003cvar translate=\"no\"\u003eMEMORY_SIZE\u003c/var\u003e: the amount of memory per database instance\n of this database cluster. We recommend setting this to 8 gigabytes per\n CPU. For example, if you set `cpu` to `2` earlier in this manifest, then\n we recommend setting `memory` to `16Gi`.\n\n - \u003cvar translate=\"no\"\u003eDISK_SIZE\u003c/var\u003e: the disk size per database instance---for\n example, `10Gi`.\n\n2. Apply the manifest file:\n\n kubectl apply -f \u003cvar translate=\"no\"\u003eDBCLUSTER_FILENAME\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDBCLUSTER_FILENAME\u003c/var\u003e: the name of the `DBCluster` manifest file created in the previous step.\n\nUse the `kubectl describe` command to verify that the database cluster resource\nis in the `READY` status.\n\nConfigure the `pgBackRest` file\n-------------------------------\n\nConfigure the `pgBackRest` file to enable the target database cluster to access\nthe Cloud Storage bucket where source backups reside.\n\n1. In your target database cluster, find the database cluster pod details:\n\n kubectl get pod -l \"alloydbomni.internal.dbadmin.goog/dbcluster=\u003cvar translate=\"no\"\u003eDB_CLUSTER_NAME\u003c/var\u003e, alloydbomni.internal.dbadmin.goog/task-type=database\"\n\n The response includes the name of the cluster database pod.\n2. Log into the pod:\n\n kubectl exec -ti \u003cvar translate=\"no\"\u003eDATABASE_POD_NAME\u003c/var\u003e -- /bin/bash\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDATABASE_POD_NAME\u003c/var\u003e: the name of the database cluster pod from the previous step.\n3. Stop the pod before updating the `pgBackRest` configuration file:\n\n supervisorctl.par stop postgres\n\n4. Create a `pgBackRest` configuration file to access backups stored in Cloud Storage:\n\n cat \u003c\u003c EOF \u003e /backup/pgbackrest.conf\n [db]\n pg1-path=/mnt/disks/pgsql/data\n pg1-socket-path=/tmp\n pg1-user=pgbackrest\n [global]\n log-path=/obs/pgbackrest\n log-level-file=info\n repo1-type=gcs\n repo1-gcs-bucket=\u003cvar translate=\"no\"\u003eGCS_SOURCE_BACKUP_BUCKET_NAME\u003c/var\u003e\n repo1-path=\u003cvar translate=\"no\"\u003eGCS_SOURCE_BACKUP_BUCKET_PATH\u003c/var\u003e\n repo1-storage-ca-file=/scripts/ca-certificates.crt\n repo1-retention-full=9999999\n repo1-gcs-key-type=auto\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eGCS_SOURCE_BACKUP_BUCKET_NAME\u003c/var\u003e: the name of the Cloud Storage bucket that you created when creating the [`BackupPlan`](/alloydb/omni/16.3.0/docs/backup-kubernetes#remote) resource manifest file for the source database cluster. This is not the full URL to the bucket; don't prefix the bucket name with `gs://`.\n - \u003cvar translate=\"no\"\u003eGCS_SOURCE_BACKUP_BUCKET_PATH\u003c/var\u003e: the path of the directory that the AlloyDB Omni operator writes backups into, within the Cloud Storage bucket for the source database cluster. The path must be absolute, beginning with `/`.\n\n The `repo1-gcs-key-type` is set to `auto` to use the instance's service\n account. For more information about other options, see [Cloud Storage Repository Key\n Type\n Option](https://pgbackrest.org/configuration.html#section-repository/option-repo-gcs-key-type).\n\nVerify source backups in the target database cluster\n----------------------------------------------------\n\nRun `pgBackRest` commands to verify that the source database cluster backups are\naccessible on the target database cluster. \n\n pgbackrest --config-path=/backup --stanza=db --repo=1 info\n\nThe following is a sample response: \n\n stanza: db\n status: ok\n cipher: none\n db (current)\n wal archive min/max (15): 000000010000000000000002/00000001000000000000000D\n full backup: 20240213-231400F\n timestamp start/stop: 2024-02-13 23:14:00+00 / 2024-02-13 23:17:14+00\n wal start/stop: 000000010000000000000003 / 000000010000000000000003\n database size: 38.7MB, database backup size: 38.7MB\n repo1: backup set size: 4.6MB, backup size: 4.6MB\n incr backup: 20240213-231400F_20240214-000001I\n timestamp start/stop: 2024-02-14 00:00:01+00 / 2024-02-14 00:00:05+00\n wal start/stop: 00000001000000000000000D / 00000001000000000000000D\n database size: 38.7MB, database backup size: 488.3KB\n repo1: backup set size: 4.6MB, backup size: 84.2KB\n backup reference list: 20240213-231400F\n\nThe timestamps in the response are used either to restore the full backup or to restore\nfrom a point in time from the recovery window.\n\nRestore the backup in the target database cluster\n-------------------------------------------------\n\nAfter you identify the backup or a point in time you want to restore to, run\n`pgBackRest` commands in your target database cluster. For more information\nabout these commands, see [Restore\nCommand](https://pgbackrest.org/command.html#command-restore).\n\nThe following are some sample `pgBackRest` restore commands:\n\n- Restore from a backup\n\n pgbackrest --config-path=/backup --stanza=db --repo=1 restore --set=20240213-231400F --type=immediate --target-action=promote --delta --link-all --log-level-console=info\n\n- Restore from a point in time\n\n pgbackrest --config-path=/backup --stanza=db --repo=1 restore --target=\"2024-01-22 11:27:22\" --type=time --target-action=promote --delta --link-all --log-level-console=info\n\nRestart the pod\n---------------\n\nAfter the restore command completes successfully, you can start the `postgres`\nprocess. \n\n supervisorctl.par start postgres\n\nAfter the `postgres` process starts, you can connect to the primary instance and\nrun queries to verify that the data is restored from the backup. For more\ninformation, see [Connect to AlloyDB Omni running on\nKubernetes](/alloydb/omni/16.3.0/docs/run-connect#kubernetes).\n\nWhat's next\n-----------\n\n- [Clone a database cluster in Kubernetes using a local backup](/alloydb/omni/16.3.0/docs/kubernetes-dr-backup-k8-local)"]]