Elasticsearch Backup

Elasticsearch backup captures all indices and their data, excluding system indices.

Backup Process:

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

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

  1. Retrieves Elasticsearch credentials from Kubernetes secrets
  2. Establishes port-forward to Elasticsearch service (automatic)
  3. Tests connectivity to the Elasticsearch cluster
  4. Uses multielasticdump to export all non-system indices
  5. Saves index data to a temporary directory
  6. Creates a compressed tar.gz archive
  7. Cleans up temporary files

Running the Backup:

./es-backup.sh

Expected Output:

========================================
Elasticsearch Backup - Elasticdump
========================================
Archive: ./elasticsearch-backup-20251103-122933.tar.gz
Checking connection... OK

✓ Connected to Elasticsearch
Starting backup...

✓ Backup completed
  Size: 40K
  Indices: 83
  Location: ./elasticsearch-backup-20251103-122933.tar.gz
  Log: ./elasticsearch-backup-20251103-122933.log

What Gets Backed Up:

  • All user-created indices (excluding system indices starting with .)

  • Index mappings and settings

  • All documents within each index

  • Index aliases and templates

Port Forwarding: The script automatically manages port-forwarding to the Elasticsearch service. No manual port-forward setup is required.

Backup File Location: Two files are created:

  • elasticsearch-backup-<timestamp>.tar.gz: The compressed backup archive

  • elasticsearch-backup-<timestamp>.log: Detailed backup log