LoginSignup
1
0

More than 1 year has passed since last update.

Amazon Elasticsearch Serviceでスナップショットを復元する方法

Last updated at Posted at 2021-07-24

はじめに

Amazon Elasticsearch Service 5.3以降では、基本的に1時間ごとに自動でスナップショットを作成し、最大で2週間分(336個)のスナップショットが作成されます。

今回は、インデックスをスナップショットから復元する手順を記述します。

手順

復元するスナップショットを特定する

最初に、復元するスナップショットを特定します。
以下のコマンドを実行することで、スナップショットの情報を取得出来ます。

curl -XGET 'https://{ESエンドポイント}/_snapshot/cs-automated/_all?pretty'

terminal
$ curl -XGET 'https://{ESエンドポイント}/_snapshot/cs-automated/_all?pretty'
{
     "snapshot" : "2021-06-15t02-19-46.**********-*******-********",
     "uuid" : "***************",
     "version_id" : ******,
     "version" : "6.3.1",
     "indices" : [ "index-1", "**********", "**********", "**********", "**********", "**********", "**********",
     ...(省略)
 },
 ...(省略)

ここでは、snapshotに記述されている2021-06-15t02-19-46.**********-*******-********をメモしましょう。

cs-autometedとは
ここにはスナップショットリポジトリ名を記述するが、自動スナップショットの場合はcs-automatedリポジトリに保存される。
スナップショットリポジトリの一覧を確認したいときは以下のコマンドを実行する。
curl -XGET '{ESエンドポイント}/_snapshot?pretty'

1つのインデックスを復元する

1つのインデックスを復元するには以下のコマンドを実行します。

curl -XPOST 'https://{ESエンドポイント}/_snapshot/cs-automated/{先程メモしたスナップショット名}/_restore?pretty' -d '{"indices": "{インデックス名}"}' -H 'Content-Type: application/json'

以下に、index-1のインデックスを復元する例を示します。

terminal
$ curl -XPOST 'https://{ESエンドポイント}/_snapshot/cs-automated/2021-06-15t02-19-46.**********-*******-********/_restore?pretty' -d '{"indices": "index-1"}'  -H 'Content-Type: application/json'
{
  "accepted" : true
}

全てのインデックスを復元する

全てのインデックスを復元するには以下のコマンドを実行します。

curl -XPOST 'https://{エンドポイント}/_snapshot/cs-automated/{スナップショット名}/_restore?pretty'

terminal
$ curl -XPOST 'https://{esエンドポイント}/_snapshot/cs-automated/2021-06-15t02-19-46.**********-*******-********/_restore?pretty'
{
  "accepted" : true
} 

検索可能なドキュメントが増えていることを確認しましょう。

Image

ドキュメントが増えていることが確認出来ました。以上です。

参考

Amazon Elasticsearch Service でのインデックスのスナップショットを作成する - Amazon Elasticsearch Service

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0