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.)

  1. Validates the snapshot file exists and is readable
  2. Displays a warning about the destructive nature of the operation
  3. Requires explicit confirmation (type 'yes' or use --yes flag)
  4. Starts a temporary restore pod
  5. Tests connectivity to the Consul service endpoint
  6. Copies the snapshot to the restore pod
  7. Restores via Consul HTTP API (PUT request)
  8. Verifies cluster health
  9. 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