elasticsearch config_error ai_generated true

SnapshotRestoreException: [repo:snapshot/xxxxx] cannot restore index [my_index] because an open index with same name already exists

ID: elasticsearch/snapshot-restore-index-already-exists

Also available as: JSON · Markdown · 中文
90%Fix Rate
90%Confidence
1Evidence
2025-02-28First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.17.0 active
8.11.0 active
8.12.0 active

Root Cause

The restore operation failed because the target cluster already has an open index with the same name as the one being restored from the snapshot.

generic

中文

恢复操作失败,因为目标集群已存在与快照中同名的打开索引。

Official Documentation

https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshot-restore.html

Workarounds

  1. 90% success Close the existing index before restoring: `POST /my_index/_close`, then restore the snapshot with the same name, and after restore, optionally open the original index or delete it.
    Close the existing index before restoring: `POST /my_index/_close`, then restore the snapshot with the same name, and after restore, optionally open the original index or delete it.
  2. 85% success Use the `rename_pattern` and `rename_replacement` options in the restore request to restore to a different index name: `POST /_snapshot/repo/snapshot/_restore {"indices": "my_index", "rename_pattern": "my_(.+)", "rename_replacement": "restored_$1"}`.
    Use the `rename_pattern` and `rename_replacement` options in the restore request to restore to a different index name: `POST /_snapshot/repo/snapshot/_restore {"indices": "my_index", "rename_pattern": "my_(.+)", "rename_replacement": "restored_$1"}`.
  3. 95% success If the existing index is not needed, delete it with `DELETE /my_index` and then restore directly.
    If the existing index is not needed, delete it with `DELETE /my_index` and then restore directly.

中文步骤

  1. Close the existing index before restoring: `POST /my_index/_close`, then restore the snapshot with the same name, and after restore, optionally open the original index or delete it.
  2. Use the `rename_pattern` and `rename_replacement` options in the restore request to restore to a different index name: `POST /_snapshot/repo/snapshot/_restore {"indices": "my_index", "rename_pattern": "my_(.+)", "rename_replacement": "restored_$1"}`.
  3. If the existing index is not needed, delete it with `DELETE /my_index` and then restore directly.

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Deleting the index removes all current data; the snapshot may not have the latest updates.

  2. 60% fail

    Renaming may break application references or alias configurations.

  3. 75% fail

    Incorrect pattern matching may overwrite unrelated indices or create duplicate names.