UGA Boxxx

つぶやきの延長のつもりで、知ったこと思ったこと書いてます

【Elasticsearch】Snapshot操作

ElasticsearchでSnapshotのキャンセルの仕方を毎回忘れるのでAPIをまとめてとく

GCSにSnapshotをあげる

滅多にやらないので忘れがち

導入のしかたは以下
GCPでElasticsearchのGCS Repository Pluginがインストールされたカスタムイメージを作ってみる - Day-to-day the memorandum

PUT _snapshot/my_gcs_repository
{
  "type": "gcs",
  "settings": {
    "bucket": "elasticsearch-snapshot"
  }
}

Snapshot削除

DELETE _snapshot/my_gcs_repository/snapshot_1

リポジトリからスナップショットが削除されると、同時に他のスナップショットでは使用されていないすべてのファイルを削除する

Snapshotの実行

PUT /_snapshot/my_gcs_repository/snapshot_1
{
  "indices": [
    "my_index"
  ],
  "ignore_unavailable": true,
  "include_global_state": false
}

ignore_unavailableはインデックスがない場合にどうするか、trueでなくても失敗させないようにしている

include_global_state はインデックスのグローバルな状態も一緒にSnapshotをとるかの設定

Snapshotのステータス確認

実行中のSnapshotのステータス確認

GET _snapshot/my_gcs_repository/my_index/_status

参考

https://www.elastic.co/guide/en/elasticsearch/reference/6.8/modules-snapshots.html