如何从备份还原到新索引?

时间:2018-08-08 06:42:53

标签: elasticsearch

从备份中还原数据时,我有些困惑。我使用以下命令创建了索引的备份:

PUT /_snapshot/my_backup
{
  "type": "fs",
  "settings": {
    "location": "D:\\my_backup"
  }
}


PUT /_snapshot/my_backup/snapshot_1?wait_for_completion=true
{
  "indices": "customers",
  "ignore_unavailable": true,
  "include_global_state": false
}

然后,我从我的elasticsearch中删除所有索引。现在,我想从备份中恢复。我能怎么做?我检查了文档,然后感到更加困惑。

此刻我尝试关注

POST /_snapshot/my_backup/snapshot_1/_restore
{
  "indices": "ecommerce",
  "ignore_unavailable": "true",
  "include_global_state": false,
  "rename_pattern": "ecommerce",
  "rename_replacement": "jal1"
}

请任何帮助。我想从给定的备份中恢复。

1 个答案:

答案 0 :(得分:2)

尝试检查备份数据的索引名称。您可以尝试

GET http://localhost:9200/_snapshot/my_backup/_all

您可以找到提供的索引名称。

现在,您可以将帖子查询与上述查询中的索引一起使用

POST /_snapshot/my_backup/snapshot_1/_restore
{
  "indices": "your_indices_name",
  "ignore_unavailable": "true",
  "include_global_state": false,
  "rename_pattern": "your_indices_name",
  "rename_replacement": "your_new_indices_name"
}

我希望这对您有用。