This page provides an overview of volume data restore policies. It also explains how to configure volume data restore policy bindings and overrides.
Overview
The volume data restore policy defines how to restore volume data from a backup. You can configure it at the restore plan level. It has the following policy options:
- Provision new volumes and restore volume data from backup: New persistent volumes (PVs) are restored using the corresponding volume backup data in the backup.
- Reuse existing volumes containing your data: PVs are pre-provisioned using the volume handle of the original PV in the backup.
- Don't restore volume data: PVs aren't restored. Backup for GKE only restores the selected persistent volume claims (PVCs) and expects the corresponding storage driver to either dynamically provision blank PVs or bind them to pre-provisioned PVs created out-of-band.
For instructions on creating a restore plan with volume data restore policy, see Create a restore plan.
There are a few reasons why you might want to define custom volume restore behavior apart from the default volume data restore policy:
- To restore a workload with a storage environment that includes different types of volumes with varying levels of data backup support. For example, your workload may contain NFS volumes and Persistent Disk volumes.
- To apply a different restore process to a specific volume.
Backup for GKE provides two mechanisms for defining custom volume restore behavior:
- Volume type specific bindings, which you can define as part of a restore plan.
- Volume specific overrides, which you can define as part of a restore.
Volume data restore policy selection process
During the restore process, Backup for GKE selects the appropriate volume restore policy for each PersistentVolumeClaim (PVC) using the following sequence:
- Before any transformation rules are applied, each PVC to be restored moves through a selection process and applies the first in-scope policy.
- If the PVC is not bound to a backed up PersistentVolume (PV), only the PVC configuration is restored. This doesn't include any data.
- If the PVC is included in a volume data restore policy override, the override policy takes precedence.
- If the PVC's volume type is included in a volume data restore policy binding, the binding policy is applied.
- If none of the earlier conditions match, the PVC uses the default volume data restore policy.
Volume data restore policy bindings
The volume data restore policy bindings let you restore volume data with a policy for a specific volume type. This policy takes precedence over the default volume restore policy. The volume data restore policy binding is only supported for Compute Engine Persistent Disks.
gcloud
Add volume data restore policy bindings to an existing restore plan:
gcloud beta container backup-restore restore-plans update RESTORE_PLAN \
--project=PROJECT_ID \
--location=LOCATION \
--volume-data-restore-policy-bindings=[VOLUME_TYPE=POLICY,...]
Replace the following:
RESTORE_PLAN
: the name of the restore plan that you want to update.PROJECT_ID
: the ID of your Google Cloud project.LOCATION
: the compute region for the resource, such asus-central1
.VOLUME_TYPE=POLICY
: binds a supported volume type to a volume data restore policy. For example,gce-persistent-disk=restore-volume-data-from-backup
creates a binding that results in Persistent Disk volumes being restored using the Restore volume data from backup policy.
Console
Use the following instructions to add bindings to an existing restore plan in the Google Cloud console:
In the Google Cloud console, go to the Google Kubernetes Engine page.
In the navigation menu, click Backup for GKE.
Click the Restore plans tab.
Click the restore plan name.
Click the Details tab.
In the Restore configuration section, click Edit that is next to Scope.
In the Define policy override for specific volume types section, click the GCE Persistent Disk checkbox.
From the Volume data restore policy list, choose a restore policy type that you want to use for Compute Engine Persistent Disk.
Click Save changes.
Volume data restore policy overrides
The volume data restore policy overrides define how to restore specific volumes. Volumes are selected by their PVC namespaces and PVC names. You can include multiple volumes in a single override.
Overrides don't enforce unique scoping, unlike bindings. This means that during volume restoration, the policy from the latest override that matches a volume's namespace and name is used.
Override example
The following example overrides ns-1/test-pvc
and ns-1/test-pvc-2
to use
the Reuse existing volumes containing your data policy and ns-2/test-pvc-3
to use the Don't restore volume data policy.
volumeDataRestorePolicyOverrides:
- policy: REUSE_VOLUME_HANDLE_FROM_BACKUP
selectedPvcs:
namespacedNames:
- namespace: ns-1
name: test-pvc
- namespace: ns-1
name: test-pvc-2
- policy: NO_VOLUME_DATA_RESTORATION
selectedPvcs:
namespacedNames:
- namespace: ns-2
name: test-pvc-3
gcloud
Create a restore with overrides:
gcloud beta container backup-restore restores create RESTORE \
--project=PROJECT_ID \
--location=LOCATION \
--restore-plan=RESTORE_PLAN \
--backup=BACKUP \
--volume-data-restore-policy-overrides-file=OVERRIDES_FILE
Replace the following:
RESTORE
: the name of the restore that you want to create.PROJECT_ID
: the ID of your Google Cloud project.LOCATION
: the compute region of the parent restore plan.RESTORE_PLAN
: the name of the parent restore plan this restore is derived from.BACKUP
: the backup to restore.OVERRIDES_FILE
: the path to a YAML file that defines overrides in the schema as seen in the example.
Console
To create a volume data restore policy override, you need to provide the PVC name, PVC namespace, and a restore policy.
Use the following instructions to create a restore with overrides in the Google Cloud console:
In the Google Cloud console, go to the Google Kubernetes Engine page.
In the navigation menu, click Backup for GKE.
Click the Backups tab.
In the list of backups, find the backup that you want to restore and click Set up a restore.
Choose a restore plan from the list of plans that apply to this backup.
In the Name the restore section, enter a name and optional description for the restore.
In the Override volume data restore policy section, click Add policy and complete the following for each override:
- In PVC name, enter the name of the PVC.
- In Namespace, enter the namespace of the PVC.
- From the Volume restore policy list, choose how to restore that PVC's volume data.
Click Restore.
What's next
- Learn more about restoring a backup.