Instructions for restoring data using Longhorn backup and restore features.
-
Scale Down the PostgreSQL StatefulSet:
kubectl scale statefulset.apps/postgresql --replicas=0 -n postgresql
-
Wait for the Volume to Detach:
- Monitor the volume status until it is detached.
-
Note the Current Volume Name:
- For example:
pvc-1be4dafb-399f-40d4-ac87-205eb56c2f44
.
- For example:
-
Delete the Old Volume via Longhorn GUI:
- Navigate to the Longhorn GUI and delete the specified volume.
-
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
).
-
Wait for the Restore Process to Complete:
- Monitor the Longhorn GUI until the restore process finishes.
-
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 > selectCreate PV/PVC
- Ensure the
Create PVC
option is checked. - Ensure the
Use Previous PVC
option is checked.
- Navigate to the lonhorn GUI > Volume > at the right side of volume named
-
Wait for the PV/PVC to be Available:
- Monitor the status until the PV/PVC is available and ready for use.
-
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.
How to force a pvc to be deleted :
1- Read the pvc's detail :
2- Set it's
finalizers
tonull
:kubectl patch pvc storage-pv-claim -p '{"metadata":{"finalizers":null}}' -n app-production-storage
3- Now you can delete it easily :