# スナップショットを作成したいPathを指定する
path.repo: /usr/local/var/elasticsearch/snapshot
$ brew services restart elasticsearch
$ curl -XGET localhost:9200/_nodes/?pretty
...
"path" : {
"data" : [
"/usr/local/var/elasticsearch/"
],
"logs" : "/usr/local/var/log/elasticsearch",
"home" : "/usr/local/Cellar/elasticsearch/5.4.0/libexec",
"repo" : "/usr/local/var/elasticsearch/snapshot"
},
curl -XPUT localhost:9200/_snapshot/snapshot -d '
{
"type": "fs",
"settings": {
"location": "/usr/local/var/elasticsearch/snapshot",
"compress": true
}
}
'
curl -XPUT localhost:9200/_snapshot/snapshot/bank-$(date +%Y-%m-%d)?wait_for_completion=true -d '
{
"indices": "bank",
"ignore_unavailable": true,
"include_global_state": false
}'
{"snapshot":{"snapshot":"bank-2017-06-09","uuid":"-VkDP0CuTe-K4bN5tIbdag","version_id":5040099,"version":"5.4.0","indices":["bank"],"state":"SUCCESS","start_time":"2017-06-09T03:05:30.702Z","start_time_in_millis":1496977530702,"end_time":"2017-06-09T03:05:30.767Z","end_time_in_millis":1496977530767,"duration_in_millis":65,"failures":[],"shards":{"total":5,"failed":0,"successful":5}}}%
curl -XGET localhost:9200/_snapshot/snapshot/bank-2017-06-09?pretty
{
"snapshots" : [
{
"snapshot" : "bank-2017-06-09",
"uuid" : "-VkDP0CuTe-K4bN5tIbdag",
"version_id" : 5040099,
"version" : "5.4.0",
"indices" : [
"bank"
],
"state" : "SUCCESS",
"start_time" : "2017-06-09T03:05:30.702Z",
"start_time_in_millis" : 1496977530702,
"end_time" : "2017-06-09T03:05:30.767Z",
"end_time_in_millis" : 1496977530767,
"duration_in_millis" : 65,
"failures" : [ ],
"shards" : {
"total" : 5,
"failed" : 0,
"successful" : 5
}
}
]
}
statusがopen
のindexに対してはリストア出来ない
curl -XPOST localhost:9200/bank/_close
たとえcloseにしても、すでにあるindexのnode数が違うとリストア出来ない
curl -XPOST localhost:9200/_snapshot/snapshot/bank-2017-06-09/_restore -d '
{
"indices": "_bank",
"ignore_unavailable": true,
"include_global_state": false
}
'
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{ "add" : { "index" : "category1", "alias" : "products" } },
{ "add" : { "index" : "category2", "alias" : "products" } }
]
}'