Skip to main content
Version: v0.27 Stable

Using Velero

Use Velero​

You can use Velero to back up virtual clusters.

Ensure 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 back up the virtual cluster state.

Back up a vCluster​

Install the Velero CLI, Velero server components and run the following command:

Create a Velero backup for a vCluster namespace
velero backup create <backup-name> --include-namespaces=my-vcluster-namespace

Verify a backup was successfully created with the following command:

Verify the Velero backup status
velero backup describe <backup-name>

This should create an output similar to the following:

Velero backup output
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

...

Restore a vCluster​

After creating a backup with the Velero CLI or a scheduled backup, you can restore a vCluster using the Velero CLI:

Restore a Velero backup
velero restore create <restore-name> --from-backup <backup-name>

Verify the restore process using the following command:

Verify the Velero backup restore status
velero restore logs <restore-name>

This restores the vCluster workloads, configuration, and state in the virtual cluster namespace.

Moving vCluster

Moving a vCluster from one namespace to another can be challenging because some objects, such as cluster role bindings and persistent volumes, contain namespace references. Velero supports namespace mapping, which works in most cases, but use cautionβ€”this may not be compatible with all vCluster setups.

Use Velero inside vCluster​

You can use Velero inside vCluster to protect your workloads and data. To use Velero for backups:

  1. Enable the hostpath-mapper component in vCluster.

  2. After enabling hostpath-mapper, install the Velero CLI (as described above), connect to your vCluster, and install Velero inside the virtual cluster:

    Velero inside the virtual cluster
    velero install --provider <provider> --bucket <bucket_name> --secret-file <your_secret_file> --plugins velero/velero-plugin-for-<provider>:<semver> --use-restic
    note

    Replace provider, bucket_name, secret-file, and other placeholders with the correct values for your environment.

  3. After installation is complete, check the status of the Velero resources:

    Verify the status of the Velero resources
    $ kubectl get all -n velero
    NAME READY STATUS RESTARTS AGE
    pod/restic-5szkb 1/1 Running 0 118s
    pod/velero-75c5479dfd-4x7sl 1/1 Running 0 118s

    NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
    daemonset.apps/restic 1 1 1 1 1 <none> 118s

    NAME READY UP-TO-DATE AVAILABLE AGE
    deployment.apps/velero 1/1 1 1 119s

    NAME DESIRED CURRENT READY AGE
    replicaset.apps/velero-75c5479dfd 1 1 1 119s
  4. Create a backup using restic:

    Create a backup with restic
    velero backup create test1 --default-volumes-to-restic
  5. Wait for the backup to complete. Once complete, you should see the following output:

    Sample Velero backup output
    $ velero backup describe test1
    Name: test1
    Namespace: velero
    Labels: velero.io/storage-location=default
    Annotations: velero.io/source-cluster-k8s-gitversion=v1.25.0+k3s1
    velero.io/source-cluster-k8s-major-version=1
    velero.io/source-cluster-k8s-minor-version=25

    Phase: Completed

    Errors: 0
    Warnings: 0

    Namespaces:
    Included: *
    Excluded: <none>

    Resources:
    Included: *
    Excluded: <none>
    Cluster-scoped: auto

    ...