Snapshot이 저정될 경로 설정 (elasticsearch.yml 에 path.repo)
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
path.repo: ["C:\\Users\\kyungseop\\workspace\\elasticsearch\\elasticsearch-5.5.1/\\backups\\my_backup"]
Snapshot 설정 추가
PUT /_snapshot/my_backup
{
"type": "fs",
"settings": {
"compress": true,
"location": "C:\\Users\\kyungseop\\workspace\\elasticsearch\\elasticsearch-5.5.1\\backups\\my_backup"
Snapshot 설정 조회
GET /_snapshot
조회 결과
{
"my_backup": {
"type": "fs",
"settings": {
"compress": "true",
"location": "C:\\Users\\kyungseop\\workspace\\elasticsearch\\elasticsearch-5.5.1\\backups\\my_backup"
}
}
}
Snapshot 생성
PUT /_snapshot/my_backup/snapshot_1?wait_for_completion=true
생성결과
{
"snapshot": {
"snapshot": "snapshot_1",
"uuid": "e14pNC8WTPekPsQQZxdFJw",
"version_id": 5050199,
"version": "5.5.1",
"indices": [
"account"
],
"state": "SUCCESS",
"start_time": "2017-08-17T07:06:59.164Z",
"start_time_in_millis": 1502953619164,
"end_time": "2017-08-17T07:06:59.460Z",
"end_time_in_millis": 1502953619460,
"duration_in_millis": 296,
"failures": [],
"shards": {
"total": 5,
"failed": 0,
"successful": 5
}
}
}
Snapshot 결과 조회
GET /_snapshot/my_backup/_all
조회 결과
{
"snapshots": [
{
"snapshot": "snapshot_1",
"uuid": "e14pNC8WTPekPsQQZxdFJw",
"version_id": 5050199,
"version": "5.5.1",
"indices": [
"account"
],
"state": "SUCCESS",
"start_time": "2017-08-17T07:06:59.164Z",
"start_time_in_millis": 1502953619164,
"end_time": "2017-08-17T07:06:59.460Z",
"end_time_in_millis": 1502953619460,
"duration_in_millis": 296,
"failures": [],
"shards": {
"total": 5,
"failed": 0,
"successful": 5
}
}
]
}
Snapshot Restore
POST /_snapshot/my_backup/snapshot_1/_restore
Snapshot Restore 시 발생가능 에러 (index 가 사용중일때)
{
"error": {
"root_cause": [
{
"type": "snapshot_restore_exception",
"reason": "[my_backup:snapshot_1/e14pNC8WTPekPsQQZxdFJw] cannot restore index [account] because it's open"
}
],
"type": "snapshot_restore_exception",
"reason": "[my_backup:snapshot_1/e14pNC8WTPekPsQQZxdFJw] cannot restore index [account] because it's open"
},
"status": 500
}
Snapshot Restore (index close 후 restore)
elasticsearch.yml 에 path.repo 설정을 하지 않고 Snapshot 지정시 에러
{
"error": {
"root_cause": [
{
"type": "repository_exception",
"reason": "[my_backup] location [C:\\Users\\kyungseop\\workspace\\elasticsearch\\elasticsearch-5.5.1\\backups\\my_backup] doesn't match any of the locations specified by path.repo because this setting is empty"
}
],
"type": "repository_exception",
"reason": "[my_backup] failed to create repository",
"caused_by": {
"type": "repository_exception",
"reason": "[my_backup] location [C:\\Users\\kyungseop\\workspace\\elasticsearch\\elasticsearch-5.5.1\\backups\\my_backup] doesn't match any of the locations specified by path.repo because this setting is empty"
}
},
"status": 500
}