elasticsearch snapshot备份、恢复


Elasticsearch配置文件elasticsearch.yml设置仓库路径:
    path.repo: "/data/elasticsearch/backup


1、创建仓库
curl -XPUT http://127.0.0.1:9200/_snapshot/my_backup -H         'Content-Type: application/json' -d '{"type": "fs", "settings": {"location": "/data/elasticsearch/backup", "compress": true}}'

2、创建快照
curl -XPUT http://127.0.0.1:9200/_snapshot/my_backup/snapshot_2?wait_for_completion=true

3、恢复快照
curl -XPOST http://127.0.0.1:9200/_snapshot/my_backup/snapshot_1/_restore



日常操作:
查看仓库信息
json@json ~ $ curl -XGET "localhost:9200/_snapshot/my_backup?pretty"
{
  "my_backup" : {
    "type" : "fs",
    "settings" : {
      "compress" : "true",
      "location" : "/data/elasticsearch/backup"
    }
  }
}
查看所有快照
json@json ~ $ curl -XGET "localhost:9200/_snapshot/my_backup/_all?pretty"
{
  "snapshots" : [
    {
      "snapshot" : "snapshot_1",
      "uuid" : "Vtuq35gqS42E4ZBvmeZaDw",
      "version_id" : 6030299,
      "version" : "6.3.2",
      "indices" : [
        "index",
        "customer"
      ],
      "include_global_state" : true,
      "state" : "SUCCESS",
      "start_time" : "2018-08-22T11:56:49.009Z",
      "start_time_in_millis" : 1534939009009,
      "end_time" : "2018-08-22T11:56:49.177Z",
      "end_time_in_millis" : 1534939009177,
      "duration_in_millis" : 168,
      "failures" : [ ],
      "shards" : {
        "total" : 7,
        "failed" : 0,
        "successful" : 7
      }
    },
    {
      "snapshot" : "snapshot_2",
      "uuid" : "Ih6LJD-MRliLjxgGsu8VhA",
      "version_id" : 6030299,
      "version" : "6.3.2",
      "indices" : [
        "index",
        "customer"
      ],
      "include_global_state" : true,
      "state" : "SUCCESS",
      "start_time" : "2018-08-22T11:57:08.388Z",
      "start_time_in_millis" : 1534939028388,
      "end_time" : "2018-08-22T11:57:08.449Z",
      "end_time_in_millis" : 1534939028449,
      "duration_in_millis" : 61,
      "failures" : [ ],
      "shards" : {
        "total" : 7,
        "failed" : 0,
        "successful" : 7
      }
    }
  ]
}

删除快照
json@json ~ $ curl -XDELETE "localhost:9200/_snapshot/my_backup/snapshot_2"
{"acknowledged":true}
json@json ~ $ curl -XGET "localhost:9200/_snapshot/my_backup/_all?pretty"
{
  "snapshots" : [
    {
      "snapshot" : "snapshot_1",
      "uuid" : "Vtuq35gqS42E4ZBvmeZaDw",
      "version_id" : 6030299,
      "version" : "6.3.2",
      "indices" : [
        "index",
        "customer"
      ],
      "include_global_state" : true,
      "state" : "SUCCESS",
      "start_time" : "2018-08-22T11:56:49.009Z",
      "start_time_in_millis" : 1534939009009,
      "end_time" : "2018-08-22T11:56:49.177Z",
      "end_time_in_millis" : 1534939009177,
      "duration_in_millis" : 168,
      "failures" : [ ],
      "shards" : {
        "total" : 7,
        "failed" : 0,
        "successful" : 7
      }
    }
  ]
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值