Longhorn supports restoring backups, and one of the use cases for this feature is to restore data for use in a Kubernetes StatefulSet, which requires restoring a volume for each replica that was backed up.
To restore, follow the below instructions. The example below uses a StatefulSet with one volume attached to each Pod and two replicas.
In Kubernetes, create a
Persistent Volume
for each Longhorn volume that was created. Name the volumes something that can easily be referenced later for thePersistent Volume Claims
.storage
capacity,numberOfReplicas
, , andvolumeHandle
must be replaced below. In the example, we’re referencingstatefulset-vol-0
andstatefulset-vol-1
in Longhorn and usinglonghorn
as ourstorageClassName
.Create the
StatefulSet
:
Result: The restored data should now be accessible from inside the StatefulSet
.