38 lines
1.5 KiB
Bash
38 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
ENV_FILE="$ROOT/compose/.env"; [[ -f "$ENV_FILE" ]] && set -a && source "$ENV_FILE" && set +a
|
|
|
|
ES_URL="http://localhost:${ES_HTTP_PORT:-9200}"
|
|
|
|
echo "[RESTORE] Checking Elasticsearch at $ES_URL"
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' "$ES_URL/_cluster/health" || true)
|
|
if [[ "$code" != "200" ]]; then
|
|
echo "[RESTORE][ERROR] ES not reachable (code=$code). Ensure argus-es-sys is running." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "[RESTORE] Re-enabling disk threshold and clearing relaxed watermarks (transient)"
|
|
curl -sS -H 'Content-Type: application/json' -X PUT "$ES_URL/_cluster/settings" -d '{
|
|
"transient": {
|
|
"cluster.routing.allocation.disk.threshold_enabled": true,
|
|
"cluster.routing.allocation.disk.watermark.low": null,
|
|
"cluster.routing.allocation.disk.watermark.high": null,
|
|
"cluster.routing.allocation.disk.watermark.flood_stage": null
|
|
}
|
|
}' | sed -n '1,5p'
|
|
|
|
# Optionally restore default replicas to 1 (set RESTORE_DEFAULT_REPLICAS=1 to enable)
|
|
if [[ "${RESTORE_DEFAULT_REPLICAS:-0}" == "1" ]]; then
|
|
echo "[RESTORE] Setting transient default index.number_of_replicas=1"
|
|
curl -sS -H 'Content-Type: application/json' -X PUT "$ES_URL/_cluster/settings" -d '{"transient":{"index.number_of_replicas":"1"}}' >/dev/null || true
|
|
fi
|
|
|
|
echo "[RESTORE] Cluster health:"
|
|
curl -sS "$ES_URL/_cluster/health?pretty" | sed -n '1,80p'
|
|
|
|
echo "[RESTORE] Done. Verify shards and consider keeping replicas=0 for single-node deployments."
|
|
|