Elastic Search Rolling Upgrade
Overview
Steps
#!/bin/bash
#es-dump.sh
# Replace Elasticsearch cluster URL in elasticsearch_url
ELASTICSEARCH_URL="<elasticsearch URL>:9200"
# Provide the indices to take dump
EXCLUDE_INDEX_PATTERN="jaeger|monitor|kibana|fluentbit"
# Provide backup directory
BACKUP_DIR="backup"
# Provide indices output file
IDICES_OUTPUT="elasticsearch-indexes.txt"
mapfile -t INDICES < <(curl -s http://<elasticsearch URL>:9200/_cat/indices | grep -v -E "(${EXCLUDE_INDEX_PATTERN})" | awk '{print $3}')
printf "%s\n" "${INDICES[@]}" > $IDICES_OUTPUT
# Create backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
# Loop through each index and perform export
for INDEX in "${INDICES[@]}"; do
OUTPUT_FILE="${BACKUP_DIR}/${INDEX}_mapping_backup.json"
# Build the elasticdump command
ELASTICDUMP_CMD="elasticdump \
--input=${ELASTICSEARCH_URL}/${INDEX} \
--output=${OUTPUT_FILE} \
--type=mapping"
# Execute the elasticdump command
$ELASTICDUMP_CMD
# Check if the elasticdump command was successful
if [ $? -eq 0 ]; then
echo "Backup of index ${INDEX} mapping completed successfully."
else
echo "Error backing up index ${INDEX}."
fi
done
for INDEX in "${INDICES[@]}"; do
OUTPUT_FILE="${BACKUP_DIR}/${INDEX}_data_backup.json"
# Build the elasticdump command
ELASTICDUMP_CMD="elasticdump \
--input=${ELASTICSEARCH_URL}/${INDEX} \
--output=${OUTPUT_FILE} \
--type=data
--timeout=300000
--limit 10000
--skip-existing"
# Execute the elasticdump command
$ELASTICDUMP_CMD
# Check if the elasticdump command was successful
if [ $? -eq 0 ]; then
echo "Backup of index ${INDEX} completed successfully."
else
echo "Error backing up index ${INDEX}."
fi
doneRolling upgrade from v6.6.2 to v7.17.15
Steps
Rolling upgrade from v7.17.15 to v8.11.3 & security is disabled
Steps
Last updated
Was this helpful?