Elasticsearch备份数据

Elasticsearch备份数据

 

1、建立备份目录

POST _snapshot/my_backup/ 

{
    "type": "fs",
    "settings": {
        "location": "/mount/backups/my_backup",
        "max_snapshot_bytes_per_sec" : "50mb", 
        "max_restore_bytes_per_sec" : "50mb"
    }
}

注:/mount/backups/my_backup目录需要所有的节点都可以访问

2、备份

2.1、备份所有的index

PUT _snapshot/my_backup/snapshot_1?wait_for_completion=true

注:页面会block住直到备份完成,如果需要后台进行,去掉?wait_for_completion=true

2.2、备份指定的index(index_1和index_2)

PUT _snapshot/my_backup/snapshot_2
{
    "indices": "index_1,index_2"
}

3、查看备份的数据

3.1、查看所有的备份

GET _snapshot/my_backup/_all

3.2、查看指定的备份(snapshot_2)

GET _snapshot/my_backup/snapshot_2

4、删除备份

DELETE _snapshot/my_backup/snapshot_2

注:备份是增量的,不要手动删除,es提供的api会帮助你删除未被使用的snapshot

5、查看备份进度

GET _snapshot/my_backup/snapshot_3/_status

INITIALIZING:初始化
STARTED:开始备份
FINALIZING:数据迁移完成但未备份完成
DONE:备份完成
FAILED:备份失败,请查看日志

6、删除正在进行的备份

DELETE _snapshot/my_backup/snapshot_3

 

posted @ 2017-04-25 16:29  PinXiong  阅读(566)  评论(0编辑  收藏  举报