1. 全部索引存储快照及恢复

1.1 全部索引存储快照

1.1.2 全部索引注册快照存储库

1
2
3
4
5
6
7
PUT _snapshot/old_k8s-prod-info
{
"type": "fs",
"settings": {
"location": "/usr/share/elasticsearch/es-back/snapshot01"
}
}

1.1.2 快照全部索引

1
PUT _snapshot/old_k8s-prod-info/backup_all?wait_for_completion=true

1.1.3 查看快照进度

1
2
3
4
5
GET _snapshot/old_k8s-prod-info/backup_all/_status
- grep state
- started:正在同步
- success:成功
- failed:失败

1.2 恢复

1.2.1 注册快照存储库

1
2
3
4
5
6
7
PUT _snapshot/old_k8s-prod-info
{
"type": "fs",
"settings": {
"location": "/usr/share/elasticsearch/es-back/snapshot01"
}
}

1.2.2 恢复全部索引

1
POST _snapshot/old_k8s-prod-info/backup_all/_restore

1.2.3 查看快照恢复进度

1
GET _cat/recovery?v

2. 指定索引快照及恢复

2.1 指定索引快照

2.1.1 指定索引注册快照存储库

1
2
3
4
5
6
7
PUT _snapshot/old_k8s-prod-info
{
"type": "fs",
"settings": {
"location": "/usr/share/elasticsearch/es-back/snapshot1119"
}
}

2.1.2 指定索引存储快照

1
2
3
4
PUT _snapshot/old_k8s-prod-info/k8s-prod-info-2023.11.19?wait_for_completion=true
{
"indices": "k8s-prod-info-2023.11.19"
}

2.1.3 查看指定索引快照进度

1
GET _snapshot/old_k8s-prod-info/k8s-prod-info-2023.11.19/_status

2.2 恢复

2.2.1 指定索引注册快照存储库

1
2
3
4
5
6
7
PUT _snapshot/old_k8s-prod-info
{
"type": "fs",
"settings": {
"location": "/usr/share/elasticsearch/es-back/snapshot1119"
}
}

2.2.2 恢复指定索引

1
2
3
4
5
6
7
8
9
10
11
12
POST _snapshot/old_k8s-prod-info/k8s-prod-info-2023.11.19/_restore
{
"indices": "k8s-prod-info-2023.11.19"
}

# 替换索引名称恢复
POST _snapshot/old_k8s-prod-info/k8s-prod-info-2023.11.19/_restore
{
"indices": "k8s-prod-info-2023.11.19",
"rename_pattern": "k8s-prod-info-2023.11.19",
"rename_replacement": "k8s-prod-info-2023.11.19-old"
}

2.2.3 查看快照恢复进度

1
2
GET _cat/recovery?v
- 显示100%完成