Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save CaptainStealthy/6baed6e71a30f5e756894e46fafd386f to your computer and use it in GitHub Desktop.

Select an option

Save CaptainStealthy/6baed6e71a30f5e756894e46fafd386f to your computer and use it in GitHub Desktop.
Steps to restore backed-up data using Longhorn, with a PostgreSQL example.

Restore Backup with Longhorn

Instructions for restoring data using Longhorn backup and restore features.

Restore Backup

Example: Restoring PostgreSQL Data

  1. Scale Down the PostgreSQL StatefulSet:

    kubectl scale statefulset.apps/postgresql --replicas=0 -n postgresql
  2. Wait for the Volume to Detach:

    • Monitor the volume status until it is detached.
  3. Note the Current Volume Name:

    • For example: pvc-1be4dafb-399f-40d4-ac87-205eb56c2f44.
  4. Delete the Old Volume via Longhorn GUI:

    • Navigate to the Longhorn GUI and delete the specified volume.
  5. Restore the Backup to a New Volume:

    • Use the Longhorn GUI to restore the backup to a new volume.
    • Assign the new volume the same name noted in step 3 (pvc-1be4dafb-399f-40d4-ac87-205eb56c2f44).
  6. Wait for the Restore Process to Complete:

    • Monitor the Longhorn GUI until the restore process finishes.
  7. Create Persistent Volume (PV) / Persistent Volume Claim (PVC):

    • Navigate to the lonhorn GUI > Volume > at the right side of volume named pvc-1be4dafb-399f-40d4-ac87-205eb56c2f44 open operation button > select Create PV/PVC
    • Ensure the Create PVC option is checked.
    • Ensure the Use Previous PVC option is checked.

longhorn-volume-create-pv-pvc

longhorn-create-pv-pvc

  1. Wait for the PV/PVC to be Available:

    • Monitor the status until the PV/PVC is available and ready for use.
  2. Scale Up the PostgreSQL StatefulSet:

    kubectl scale statefulset.apps/postgresql --replicas=1 -n postgresql

By following these steps, you can successfully restore your data using Longhorn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment