elasticsearch备份与恢复
Posted chenzongyan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch备份与恢复相关的知识,希望对你有一定的参考价值。
备注:以下代码在kibana插件下运行:
# 创建一个备份用的仓库
# type:fs文件系统
# 支持Shared filesystem, Amazon S3, HDFS和Azure #Cloud
# location备份目录
PUT /_snapshot/my_backup { "type": "fs", "settings": { "location": "c:/mount/backups/my_backup" } }
# 修改备份仓库属性
# max——snapshot_bytes_per_sec,创建快照速度
# max_restore_bytes_per_sec,还原快照速度
POST /_snapshot/my_backup/ { "type": "fs", "settings": { "location": "/mount/backups/my_backup", "max_snapshot_bytes_per_sec" : "50mb", "max_restore_bytes_per_sec" : "50mb" } }
# 开始备份
#wait_for_completion等待完成参数,如果没有,则后台完成
PUT /_snapshot/my_backup/snapshot_1?wait_for_completion=true
# 查看快照
GET /_snapshot/my_backup/snapshot_1
# 查看所有快照
GET /_snapshot/my_backup/_all
# 快照详细信息
GET /_snapshot/my_backup/snapshot_1/_status
# 删除备份
DELETE /_snapshot/my_backup/snapshot_1
# 恢复snapshot_1里的全部索引
POST /_snapshot/my_backup/snapshot_1/_restore
# 恢复详细参数设置
# 参数indices 设置只恢复index_1索引,
# 参数rename_pattern 和rename_replacement 用来正则匹配要恢复的索引,并且重命名。
# 和备份一样,api会立刻返回值,然后在后台执行恢复,使用wait_for_completion 标记强制
# 同步执行
POST /_snapshot/my_backup/snapshot_1/_restore { "indices": "index_1", "rename_pattern": "index_(.+)", "rename_replacement": "restored_index_$1" }
# 查看恢复的状态
GET /_recovery/restored_index_3 GET /_recovery/
# 取消恢复过程不管是正在备份,还是备份完成
DELETE /restored_index_3
以上是关于elasticsearch备份与恢复的主要内容,如果未能解决你的问题,请参考以下文章