目录
1、首次创建备份文件路径:
2、首次创建备份仓库:
3、修改备份仓库的备份和存储速度:
4、查看备份仓库:
5、查看备份仓库中所有索引备份信息:
6、手动备份索引:
(1)异步备份:
(2)同步备份:
7、手动查看索引备份:
8、手动恢复索引备份:
(1)异步恢复:
(2)同步恢复:
9、手动删除索引备份:
在计算机上创建一个保存数据备份文件的路径,该路径要与elasticsearch.yml中配置的备份仓库路径一直,并且该文件夹路径授予最高权限。
http://192.168.99.164:9200/_snapshot/data_backup PUT
{
"type": "fs",
"settings": {
"compress": "true",
"location": "/wocloud/elasticsearch_backup/data_backup"
}
}
说明:备份仓库默认的备份和存储速度为20mb/s,可以通过手动修改仓库的速度,本人设置为50mb/s,可根据网络网速合理设置。
http://192.168.99.164:9200/_snapshot/data_backup POST
{
"type": "fs",
"settings": {
"compress": "true",
"location": "/wocloud/elasticsearch_backup/data_backup",
"max_snapshot_bytes_per_sec" : "50mb",
"max_restore_bytes_per_sec" : "50mb"
}
}
max_snapshot_bytes_per_sec:备份速度;
max_restore_bytes_per_sec:存储速度;
http://192.168.99.164:9200/_snapshot/data_backup?pretty GET
http://192.168.99.164:9200/_snapshot/data_backup/_all?pretty GET
http://192.168.99.164:9200/_snapshot/data_backup/t_b_company_info_backup PUT
{
"indices": "t_b_company_info"
}
说明:此命令备份是异步备份,也就是默认的备份方式,命令执行后会立即返回,备份在后台运行。
http://192.168.99.164:9200/_snapshot/data_backup/t_b_company_info_backup?wait_for_completion=true PUT
{
"indices": "t_b_company_info"
}
说明:添加了wait_for_completion参数,此命令备份是同步备份,只有等备份完成后命令才会返回,如果数据量大,可能会花费比较长的时间。
http://192.168.99.164:9200/_snapshot/data_backup/test_backup GET
http://192.168.99.164:9200/_snapshot/data_backup/test_backup/_restore POST
{
"indices": "lsy_test_one"
}
说明:此命令恢复是异步恢复,也就是默认的恢复方式,命令执行后会立即返回,恢复在后台运行。
http://192.168.99.164:9200/_snapshot/data_backup/test_backup/_restore?wait_for_completion=true POST
{
"indices": "lsy_test_one"
}
说明:添加了wait_for_completion参数,此命令恢复是同步恢复,只有等恢复完成后命令才会返回,如果数据量大,可能会花费比较长的时间。
http://192.168.99.164:9200/_snapshot/data_backup/test_backup DELETE