简体   繁体   English

如何在快照中找到 Elasticsearch 索引?

[英]How to find Elasticsearch index in snapshot?

I have an Elasticsearch cluster running on AWS where I have snapshot like this我有一个在 AWS 上运行的 Elasticsearch 集群,我有这样的快照

 {
     "snapshot": "2016-07-13_165430",
     "indices": [
        "analytical-2016-06-15",
        "analytical_2016-06-13",
        "analytical_2016-07-13",
        "operational-2016-06-15",
        "operational_2016-06-13",
        "operational_2016-07-13"
     ],
     "state": "SUCCESS",
     "start_time": "2016-10-10T23:54:33.705Z",
     "start_time_in_millis": 1476143673705,
     "end_time": "2016-10-10T23:54:44.893Z",
     "end_time_in_millis": 1476143684893,
     "duration_in_millis": 11188,
     "failures": [],
     "shards": {
        "total": 30,
        "failed": 0,
        "successful": 30
     }
  },
  {
     "snapshot": "2016-07-13_165546",
     "indices": [
        "analytical-2016-06-15",
        "analytical_2016-06-13",
        "analytical_2016-07-13",
        "operational-2016-06-15",
        "operational_2016-06-13",
        "operational_2016-07-13"
     ],
     "state": "SUCCESS",
     "start_time": "2016-10-10T23:55:48.808Z",
     "start_time_in_millis": 1476143748808,
     "end_time": "2016-10-10T23:55:52.420Z",
     "end_time_in_millis": 1476143752420,
     "duration_in_millis": 3612,
     "failures": [],
     "shards": {
        "total": 30,
        "failed": 0,
        "successful": 30
     }
  }

Now all these indices are running online with some other indices like: "analytical-2016-06-15",现在所有这些指数都与其他一些指数一起在线运行:“analytical-2016-06-15”,
"analytical_2016-06-13", "analytical_2016-06-13",
"analytical_2016-07-13", "analytical_2016-07-13",
"operational-2016-06-15", "操作-2016-06-15",
"operational_2016-06-13", "operational_2016-06-13",
"operational_2016-07-13" “操作_2016-07-13”
"operational_2016-09-13" “操作_2016-09-13”
.... ....

I need to check if my indices are backed up or not, and if already backed up in which snapshot it exists.我需要检查我的索引是否已备份,以及是否已备份它存在于哪个快照中。

I suspect @air is (was) interested in finding which of many snapshots contain a given index;我怀疑@air 对查找包含给定索引的许多快照中的哪一个感兴趣; the pasted example was just one view of snapshot history.粘贴的示例只是快照历史记录的一种视图。 When you've been taking daily snapshots over a span of time, and indices have been added/removed, it would be a chore to search manually.当您在一段时间内拍摄每日快照并添加/删除索引时,手动搜索将是一件苦差事。

There doesn't seem to be an API invocation for "find me all snapshots containing index operational_2021-06-10 " but here's an automation option:似乎没有“找到我所有包含索引operational_2021-06-10 _2021-06-10的快照”的API调用,但这里有一个自动化选项:

 curl -XGET "http://cluster:9200/_snapshot/myrepo/*" |
   jq -c '.snapshots[] | select(.indices | index("operational_2021-06-10")) | { snapshot }'

{"snapshot":"daily-snap-2021.06.10-hjmskkjsryyq82asmxiuva"}
{"snapshot":"daily-snap-2021.06.11-eayyiiort0cx97r_jscara"}
{"snapshot":"daily-snap-2021.06.12-rmrsbmsespgf0_czu721hw"}
{"snapshot":"daily-snap-2021.06.13-meeoachori61w5r3n3qzaq"}
{"snapshot":"daily-snap-2021.06.14-espbnhuprcckqylk3xltwq"}
{"snapshot":"daily-snap-2021.06.15-sbosayasthinaudxaqw3pa"}

I'm confused by your question as you have posted snapshot json which tells you exactly which indices are backed up in each snapshot.我对你的问题感到困惑,因为你发布了快照 json,它告诉你每个快照中备份了哪些索引。 You need to go through each snapshot each in each snapshot repository (which I think you already know how to do) and look at the indices in each snapshot.您需要遍历每个快照存储库中的每个快照(我认为您已经知道该怎么做)并查看每个快照中的索引。

This is the only way AFAIK to determine which indices have been backed up, when and by which snapshots.这是 AFAIK 确定已备份哪些索引、何时以及由哪些快照备份的唯一方法。

Here is the documentation to the snapshot api: https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html这是快照 api 的文档: https : //www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM