Restore indices on snapshots based on their alias

When restoring indices from a snapshot, is there a way to get from the snapshot the aliases associated with an index before starting to restore the index? Through the REST API I can get information about the indices that are in a snapshot, the number of shards and the total size, but I couldn't find any way of getting the aliases that may be associated with that index.

To give some context on what we are trying to do, our application refers to the indexes through aliases. Periodically, we create a new index and once this is done, we switch the alias and delete the old index. But it may happen that this fails and we are left with partially or fully created indexes without having an alias. We clean from time to time the orphaned indexes, but they will sometimes end up in the snapshots. So when we restore, we would like to only restore the indices that have an alias.

All this is performed by automation and there may be failures at any step, so we would like to find a way that the system will never end up in a bad state.

Currently, I see two options, neither of them satisfactory:

  • Restore with aliases and when done, delete the indexes that are being replaced, which also deletes the association of the alias to the indexes being replaced. But if the second step fails, we end up with an alias pointing to the current and the restored indexes, which will break our application.
  • Restore without alias and update the alias ourselves. But if there are multiple versions of the index that can match a given alias, we don't know which one to restore and associate with the alias.

If we could get the aliases of an index in a snapshot, then we would always know which index to restore and could restore without alias and update the alias at the end, in an atomic operation. If the restore would fail, no problem, because there will still be a single index associated with the alias.

Thanks in advance for any assistance

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.