Home > OS >  Elasticsearch restore snapshot in a new single node cluster
Elasticsearch restore snapshot in a new single node cluster

Time:09-28

I've made a snapshot using default settings:

PUT /_snapshot/backup/?wait_for_completion=true

Deleted old data, an tried to restore it on a new elasticsearch single node cluster:

POST /_snapshot/backup/snapshot-2021.09.23/_restore , but I get error:

"type" : "snapshot_restore_exception",
"reason" : "[backup:snapshot-2021.09.23/esJtA1MeRcenJbz3tkIL2A] cannot restore index [.geoip_databases] because an open index with same name already exists in the cluster. Either close or delete the existing index or restore the index under a different name by providing a rename pattern and replacement name"

I want to do a simple snapshot restore... these guys at ES manage to over-complicate even a simple backup-restore operation.

I think the index in error is a system index. If so, can I restore my snapshot before system indexes are created?

How can I restore my snapshot?

Elasticsearch 7.14.1


I've also tried using:

POST /_snapshot/backup/snapshot-2021.09.23/_restore
{
  "include_global_state":false,
  "feature_states":[]
}

but the same error shows.

CodePudding user response:

If you read the error message it should be pretty clear:

[backup:snapshot-2021.09.23/esJtA1MeRcenJbz3tkIL2A] cannot restore index [.geoip_databases] because an open index with same name already exists in the cluster. Either close or delete the existing index or restore the index under a different name by providing a rename pattern and replacement name"

So you have three choices:

A. Delete the index before doing the restore

DELETE index-name
POST /_snapshot/backup/snapshot-2021.09.23/_restore

B. Close the index before doing the restore and then it is reopened automatically after the restore operation is complete

POST index-name/_close
POST /_snapshot/backup/snapshot-2021.09.23/_restore

C. Restore the index under a different name

POST /_snapshot/backup/snapshot-2021.09.23/_restore
{
  "indices": "index-name",
  "ignore_unavailable": true,
  "include_global_state": false,              
  "rename_pattern": "(. )",
  "rename_replacement": "$1_restored",
  "include_aliases": false
}

But since we're talking about a system index, it's a bit different, you need to proceed differently and restore the index via feature states:

POST /_snapshot/backup/snapshot-2021.09.23/_restore
{
  "feature_states":[ "geoip" ]
}

Adding flexibility for different use cases is not over-complicating :-)

CodePudding user response:

Opened github issue: https://github.com/elastic/elasticsearch/issues/78320

As a workaround I've managed to restore my snapshot by selecting the indices with wildcard so that it excludes the problematic system index:

POST /_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true
{
  "indices": "my-index-*,my-other-index-*",
}
  • Related