Velero backup fails with "pod volume backup failed: error getting volume path on host: expected one matching path, got 0"
search cancel

Velero backup fails with "pod volume backup failed: error getting volume path on host: expected one matching path, got 0"

book

Article ID: 323915

calendar_today

Updated On:

Products

Tanzu Mission Control

Issue/Introduction

Symptoms:

When utilizing Velero for backing up kubernetes pods, you see the following error from the velero backup logs.

 

Example, from the command:

velero backup logs VELERO_BACKUP_NAME

 

You see the error:

level=error msg="Error backing up item" backup=velero/VELERO_BACKUP_NAME error="pod volume backup failed: error getting volume path on host: expected one matching path, got 0"



Cause

This happens when using Restic to backup a Pod's hostPath volume. Volumes of type hostPath are not supported.  This is a known limitation in Velero Restic integration.

https://velero.io/docs/v1.8/restic/#limitations

 

Furthermore, within VMware Tanzu Mission Control (TMC), the Data Protection capability also utilizes OSS Velero.

 

Before March 29, 2022, users of TMC DP had to manually annotate each pod for which the volumes were to be backed up using Restic. This was the "opt-in" approach: https://velero.io/docs/v1.8/restic/#using-opt-in-pod-volume-backup.

 

Therefore, any backup/schedule created without this annotation on pods actually skips the backup of volumes attached to the pods.

 

Then on March 29, 2022, TMC DP switched to the "opt-out" approach, where users had to annotate the pods, for which the volumes were NOT to be backed up using Restic. In TMC, now by default, all volumes are automatically backed up. This removed the tedious manual work needed to annotate each pod with volumes: https://velero.io/docs/v1.8/restic/#using-the-opt-out-approach

 

Resolution

Follow the steps in the "opt-out" approach to add the following annotation on the pods to have pod volumes excluded from backups:

 

backup.velero.io/backup-volumes-excludes

 

Refer to the steps in the OSS Velero documentation:

https://velero.io/docs/v1.8/restic/#using-the-opt-out-approach