個人學習筆記,謝絕轉載!!!
原文:https://www.cnblogs.com/wshenjin/p/16072599.html
創建快照倉庫
curl -H "Content-Type: application/json" -XPOST http://127.0.0.1:9200/_snapshot/EsSnapshot -d '{
"type": "fs",
"settings": {
"compress" : "true",
"location": "/data/backup/elasticsearch_snapshot"
}
}'
共享文件系統倉庫(“type”: “fs”)使用共享文件系統存快照,如果要注冊共享文件系統倉庫,必須在所有master和data節點掛載相同的共享文件系統到同一個路徑位置。
這個路徑位置(或者它的一個父目錄)必須在所有master和data節點的path.repo設置上注冊。
查看快照倉庫
curl -XGET http://127.0.0.1:9200/_snapshot
查看快照倉庫列表
curl 127.0.0.1:9200/_cat/repositories?v
刪除快照倉庫
curl -XDELETE http://127.0.0.1:9200/_snapshot/EsSnapshot
創建快照
curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/_snapshot/EsSnapshot/snapshot_20220328?wait_for_completion=true -d '{
"indices":"index1,index2", ##不寫就全部
"ignore_unavailable": true,
"include_global_state": false
}'
indices:指定要包含到快照的索引列表
ignore_unavailable:設置為 true 時,在創建快照時會忽略不存在的索引。默認情況下,如果選項 ignore_unavailable 沒有設值,一個索引缺失,快照請求會失敗。
include_global_state:為 false,可以阻止集群全局狀態信息被保存為快照的一部分。默認情況下,如果如果一個快照中的一個或者多個索引沒有所有主分片可用,整個快照創建會失敗,該情況可以通過設置 partial 為 true 來改變。
查看快照
curl -XGET http://127.0.0.1:9200/_snapshot/EsSnapshot/snapshot_20220328
刪除快照
curl -XDELETE http://127.0.0.1:9200/_snapshot/EsSnapshot/snapshot_20220328
從快照中恢復
curl -H "Content-Type: application/json" -XPOST http://127.0.0.1:9200/_snapshot/EsSnapshot/snapshot_20220328/_restore?wait_for_completion=true -d '{
"indices":"index1,index2" ##不寫就全部
}'
默認情況下,快照中的所有索引將被恢復,集群狀態不被恢復。
可以通過在恢復請求中使用 indices 和 include_global_state 選項來指定要恢復的索引和允許恢復集群全局狀態。
索引列表支持多索引語法: rename_pattern 和 rename_replacement 選項在恢復時通過正則表達式來重命名索引。
設置 include_aliases 為 false 可以防止與索引關聯的別名被一起恢復。
