Elasticsearch Restore

Restore Elasticsearch last to populate search indices and analytics data.

Restore Process:

The es-restore.sh script performs the following operations:

(Click the file name above to download the script.)

  1. Validates the backup archive exists and is a .tar.gz file
  2. Displays a warning about index replacement
  3. Requires explicit confirmation (type 'yes' or use --yes flag)
  4. Retrieves Elasticsearch credentials
  5. Extracts the archive to a temporary directory
  6. Establishes port-forward to Elasticsearch service (automatic)
  7. Tests connectivity and records current index count
  8. Uses multielasticdump to restore all indices
  9. Waits for cluster to settle (30 seconds)
  10. Verifies index count and cluster health
  11. Cleans up temporary files

Running the Restore:

./es-restore.sh elasticsearch-backup-20251103-122933.tar.gz

Or skip confirmation prompt:

./es-restore.sh elasticsearch-backup-20251103-122933.tar.gz --yes

Expected Output:

========================================
Elasticsearch Restore - Elasticdump
========================================

WARNING: This restore will overwrite indices in the target cluster.
- Indices may be deleted and recreated
- Mappings and settings will be applied from the backup
- Any divergent data may be lost

Type 'yes' to continue: yes
Backup: elasticsearch-backup-20251103-122933.tar.gz
Checking connection... OK
Indices before restore: 0

Starting restore...
[restore progress messages]

✓ Restore completed
  Indices before: 0
  Indices after: 83
  Cluster health: green

✓ Restoration verified

Verification: After restore, verify Elasticsearch data:

# List all indices
curl -u elastic:<password> http://localhost:9200/_cat/indices?v

# Check cluster health
curl -u elastic:<password> http://localhost:9200/_cluster/health?pretty

# Verify document counts
curl -u elastic:<password> http://localhost:9200/_cat/count?v

# Test search functionality
curl -u elastic:<password> http://localhost:9200/<index-name>/_search?size=1