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 scale down and up a postgresql statefulset :
How disable auto-sync in the argocd application and then scale it down and up :
1- Select the application and click on the
DETAILS
button up left corner :2- At the
Sync Policy
section, hit theDISABLE AUTO-SYNC
:3- Now you can easily manage to scale down or up :