Consul Restore
Restore Consul first to establish service discovery and configuration.
Restore Process:
The consul-restore.sh script performs
the following operations:
(Click the file name above to download the script.)
- Validates the snapshot file exists and is readable
- Displays a warning about the destructive nature of the operation
- Requires explicit confirmation (type 'yes' or use --yes flag)
- Starts a temporary restore pod
- Tests connectivity to the Consul service endpoint
- Copies the snapshot to the restore pod
- Restores via Consul HTTP API (PUT request)
- Verifies cluster health
- Cleans up the temporary pod
Running the Restore:
./consul-restore.sh consul-backup-20251103-121841.snap
Or skip confirmation prompt:
./consul-restore.sh consul-backup-20251103-121841.snap --yes
Expected Output:
========================================
Consul Restore Script
========================================
WARNING: This restore will overwrite current Consul state.
- Service registrations will be replaced
- Key/value store will be replaced
- ACLs and configurations will be replaced
- Proceed only if you understand the risk
Type 'yes' to continue: yes
[i] Starting restore pod...
[✓] Restore pod ready
[i] Testing Consul endpoint...
[✓] Connected to Consul
[i] Copying snapshot to pod...
[✓] Snapshot copied
[i] Restoring Consul snapshot...
[✓] Restore completed (HTTP 200)
[i] Verifying cluster health...
[✓] Cluster healthy
========================================
Restore Complete
========================================
File: consul-backup-20251103-121841.snap
Verification: After restore, verify Consul data:
# Check service registrations
kubectl exec -it <consul-pod> -- consul catalog services
# Verify key-value store
kubectl exec -it <consul-pod> -- consul kv get -recurse
# Check cluster members
kubectl exec -it <consul-pod> -- consul members