ES索引的备份与恢复
1.索引的备份与恢复
步骤首先是进行创建备份仓库这里选择如下:/usr/local/backup
在es的yml下进行添加配置
path.repo: ["/usr/local/backup"]
然后在kibana中执行
PUT /_snapshot/my_fs_backup
{
"type": "fs",
"settings": {
"location": "/usr/local/backup",
"compress": true
}
}
创建索引写入数据
PUT test
{
"settings" : {
"number_of_shards" : 3,
"number_of_replicas" : 0
}
}
POST _bulk
{ "index" : { "_index" : "test", "_id" : "1" } }
{ "msg" : "value1" }
{ "index" : { "_index" : "test", "_id" : "2" } }
{ "msg" : "value2" }
{ "index" : { "_index" : "test", "_id" : "3" } }
{ "msg" : "value3" }
{ "index" : { "_index" : "test", "_id" : "4" } }
{ "msg" : "value4" }
{ "index" : { "_index" : "test", "_id" : "5" } }
{ "msg" : "value5" }
为上述索引创建一个snapshot
PUT /_snapshot/my_fs_backup/snapshot_test_1?wait_for_completion=true
{
"indices": "test",
"ignore_unavailable": true,
"include_global_state": false
}
可以查看存储库路径,/usr/local/backup,里面有内容。
删除上述索引
DELETE test
恢复上述索引
POST /_snapshot/my_fs_backup/snapshot_test_1/_restore
{
"indices": "test",
"ignore_unavailable": true,
"include_global_state": true
}
查看检查索引数据
GET test/_search
GET test/_settings