If the whole Kubernetes cluster or Longhorn system goes offline, the following steps can be used to retrieve the data of the volume.

    1. Check the path found in step 1 to see if it contains the data.

      The data will be stored in the /replicas directory, for example:

      1. # ls /var/lib/longhorn/replicas/
      2. pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc-d890efb2

      The directory naming pattern is:

      So in the example above, there are two volumes stored here, which are pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc and .

      The volume name matches the Kubernetes PV name.

    2. Use the lsof command to make sure no one is currently using the volume, e.g.

      1. # lsof pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc-d890efb2/
      2. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    3. Check the volume size of the volume you want to restore using the following command inside the directory:

      From the result above, you can see the volume size is (1 GiB). Note the size.

    4. To export the content of the volume, use the following command to create a single replica Longhorn volume container:

      1. docker run -v /dev:/host/dev -v /proc:/host/proc -v <data_path>:/volume --privileged longhornio/longhorn-engine:v1.1.1 launch-simple-longhorn <volume_name> <volume_size>

      For example, based on the information above, the command should be:

    Result: Now you should have a block device created on /dev/longhorn/<volume_name> for this device, such as /dev/longhorn/pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc for the example above. Now you can mount the block device to get the access to the data.