is it possible to create new PVC from snapshot or backup with yalm file?
You can create StorageClass, and provide backup URL to fromBackup parameter, then create a PVC from that StorageClass, new Longhorn volume gets created, and will restore data from the specified backup
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: <STORAGE_CALSS_NAME>
provisioner: driver.longhorn.io
allowVolumeExpansion: true
parameters:
numberOfReplicas: "3"
staleReplicaTimeout: "2880" # 48 hours in minutes
fromBackup: "<BACKUP_URL>"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: <PVC_NAME>
spec:
accessModes:
- ReadWriteOnce
storageClassName: <STORAGE_CALSS_NAME>
resources:
requests:
storage: <PVC_SIZE>
@meldafrawi
what's
@hillbun
In backup page, select volume backup, and from right drop down menu of the backup, you click on Get URL

@meldafrawi
But I can not define pvc and pod in a yalm file, it will cause error:
Warning FailedAttachVolume 1s (x5 over 9s) attachdetach-controller AttachVolume.Attach failed for volume "pvc-2feb8497-526e-4556-b927-cea5b282b613" : rpc error: code = Internal desc = Action [attach] not available on [&{pvc-2feb8497-526e-4556-b927-cea5b282b613 volume map[self:http://longhorn-backend:9500/v1/volumes/pvc-2feb8497-526e-4556-b927-cea5b282b613] map[]}]
I must write 2 yalm file for pvc and pod to avoid this error.
any advice?
I guess the volume created from the backup takes a long time, which exceeds the max wait interval of pod volume attachment. Then the pod keeps retrying attaching the volume and report this error.
Creating a volume from backup means Longhorn volume needs to restore data from backup. It may be time-consuming. And we cannot config the wait interval for the pod attachment. Hence now I think it's better to create the volume/PVC and wait for the volume ready first. Then you can create a pod with the PVC.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
I guess the volume created from the backup takes a long time, which exceeds the max wait interval of pod volume attachment. Then the pod keeps retrying attaching the volume and report this error.
Creating a volume from backup means Longhorn volume needs to restore data from backup. It may be time-consuming. And we cannot config the wait interval for the pod attachment. Hence now I think it's better to create the volume/PVC and wait for the volume ready first. Then you can create a pod with the PVC.