// Module included in the following assembly:
//
// * hosted_control_planes/hcp_high_availability/hcp-backup-restore-virt.adoc

:_mod-docs-content-type: PROCEDURE
[id="restore-hosted-cluster-virt_{context}"]
= Restoring a hosted cluster on {VirtProductName}

[role="_abstract"]
After you back up a hosted cluster on {VirtProductName}, you can restore the backup.

[NOTE]
====
The restore process can be completed only on the same management cluster where you created the backup.
====

.Procedure

. Ensure that no pods or persistent volume claims (PVCs) are running in the `HostedControlPlane` namespace.

. Delete the following objects from the management cluster:

** `HostedCluster`
** `NodePool`
** PVCs

. Create a restoration manifest YAML file that is similar to the following example:
+
[source,yaml]
----
apiVersion: velero.io/v1
kind: Restore
metadata:
  name: hc-clusters-hosted-restore
  namespace: openshift-adp
spec:
  backupName: hc-clusters-hosted-backup
  restorePVs: true
  existingResourcePolicy: update
  excludedResources:
  - nodes
  - events
  - events.events.k8s.io
  - backups.velero.io
  - restores.velero.io
  - resticrepositories.velero.io
----
+
* `spec.restorePVs` starts the recovery of pods with the included persistent volumes.
* `spec.existingResourcePolicy: update` ensures that any existing objects are overwritten with backup content. This action can cause issues with objects that contain immutable fields, which is why you deleted the `HostedCluster`, node pools, and PVCs. If you do not set this policy, the Velero engine skips the restoration of objects that already exist.

. Apply the changes to the YAML file by entering the following command:
+
[source,terminal]
----
$ oc apply -f <restore_resource_file_name>.yaml
----
+
Replace `<restore_resource_file_name>` with the name of your file.

. Monitor the restore process by checking the restore status field and the Velero logs.
+
** To check the restore status field, enter the following command:
+
[source,terminal]
----
$ watch "oc get restores.velero.io -n openshift-adp <backup_file_name> -o jsonpath='{.status}' | jq"
----
+
** To check the Velero logs, enter the following command:
+
[source,terminal]
----
$ oc logs -n openshift-adp -ldeploy=velero -f
----

.Verification

* When the `status.phase` field is `Completed`, the restore process is considered complete.

.Next steps

* After some time, the KubeVirt VMs are created and join the hosted cluster as compute nodes. Make sure that the hosted cluster workloads are running again as expected.