Skip to main content

Backup & Restore

Backing up and restoring a virtual cluster usually means to backup the namespace where vcluster is installed in. If you are using an external datastore like MySQL or Postgresql that is not running inside the same namespace as vcluster, you will need to create a separate backup for the datastore as well. Please refer to the appropriate docs for doing that.

Using velero#

We recommend velero to backup virtual clusters, as it supports PV backup as well as single namespace backups. Other backup solutions should usually work as well.

Make sure your cluster supports volume snapshots to allow velero to backup persistent volumes and persistent volume claims that save the virtual cluster state. Alternatively, you can use velero's restic integration to backup the virtual cluster state.

Backing up a vcluster#

Make sure to install the velero cli, velero server components and run the following command:

velero backup create <backup-name> --include-namespaces=my-vcluster-namespace

Verify backup was created successfully with:

velero backup describe <backup-name>

This should create a similar output to:

Name: <backup-name>
Namespace: velero
Labels: velero.io/storage-location=default
Annotations: velero.io/source-cluster-k8s-gitversion=v1.24.0
velero.io/source-cluster-k8s-major-version=1
velero.io/source-cluster-k8s-minor-version=24
Phase: Completed
Errors: 0
Warnings: 0
Namespaces:
Included: test
Excluded: <none>
Resources:
Included: *
Excluded: <none>
Cluster-scoped: auto
...

Restoring a vcluster#

After you have created a backup through either the velero cli or a schedule, you can restore a vcluster from the created backup via the velero cli:

velero restore create <restore-name> --from-backup <backup-name>

Verify the restore process via:

velero restore logs <restore-name>

This should recreate the vcluster workloads, configurations as well as vcluster state in the virtual cluster namespace.

Moving vclusters

Currently its quite difficult to move a vcluster from one namespace to another as there are objects that include a namespace reference such as the cluster role bindings or persistent volumes. velero supports namespace mapping that should work in most cases, but caution is still required as this might not work for every vcluster setup.