본문 바로가기

리눅스

[리눅스] Elasticsearch Snapshot and Restore

728x90

Elasticsearch Snapshot and Restore

sapshot용 repository 생성

docker-compose.yml 편집

vim docker-compose.yml

path.repo=/usr/share/elasticsearch/esbackup 추가

    environment:
...
      - bootstrap.memory_lock=true
      - path.repo=/usr/share/elasticsearch/esbackup
      - xpack.security.enabled=true
...
    volumes:
...
      - ./esbackup:/usr/share/elasticsearch/esbackup

esbacup 디렉터리 생성 및 권한 변경

mkdir esbackup; chown 1000.1000 esbackup

elasticsearch 재기동

docker-compose up -d

백업 repository  생성

- postman tools 사용

PUT /_snapshot/esbackup
{
  "type": "fs",
  "settings": {
    "compress": true,
    "location": "/usr/share/elasticsearch/esbackup"
  }
}

생성된 repository 확인

- postman tools

- curl 명령

curl -s -XGET "https://localhost:9200/_snapshot/esbackup?pretty" -u "elastic:elastic1!" --cacert ../certs/ca/ca.crt
$ curl -s -XGET "https://localhost:9200/_snapshot/esbackup?pretty" -u "elastic:elastic1!" --cacert ../certs/ca/ca.crt
{
  "esbackup" : {
    "type" : "fs",
    "uuid" : "TYTSt56xRkGWIz5JRfppEw",
    "settings" : {
      "compress" : "true",
      "location" : "/usr/share/elasticsearch/esbackup"
    }
  }
}

index 목록 확인

curl -s -XGET "https://localhost:9200/_cat/indices?pretty" -u "elastic:elastic1!" --cacert ../certs/ca/ca.crt
$ curl -s -XGET "https://localhost:9200/_cat/indices?pretty" -u "elastic:elastic1!" --cacert ../certs/ca/ca.crt
green open efk-debug.test4-20220622        I1YIuJLqSoWF--Amo_jVLA 1 1     1     0  9.9kb   4.9kb
green open efk-debug.test5-20220622        fXq1hUfgTW2E0XEgzZfQrg 1 1     1     0  9.9kb   4.9kb
green open efk-debug.test6-20220622        OSYFB5c2S_2mYwnYAMaC-g 1 1     1     0  9.9kb   4.9kb
green open efk-debug.test3-20220622        R2Cr6rinT3Ou_tgm0Hhc2g 1 1     1     0  9.9kb   4.9kb
green open efk-debug.test2-20220622        i8XHQ71cQA2bwnNZc7ruLA 1 1     1     0  9.9kb   4.9kb
green open .monitoring-kibana-7-2022.06.22 _VRnTJMgQMOwfNwcfZDH8Q 1 1  8098     0  3.2mb   1.5mb
green open .monitoring-es-7-2022.06.23     pLzHkDHTQBCka3limWENxQ 1 1 39378 14960 68.2mb  24.6mb
green open .monitoring-es-7-2022.06.22     GZGQBpi2RVGdT3wOm_IM9g 1 1 72519     0   88mb  36.4mb
green open efk-debug.test-20220622         8KU119gATL2P8B_6X6IihQ 1 1     2     0 19.4kb   9.7kb
green open efk-debug.test1-20220622        vQSskikIRxmRFFwq9v6xHg 1 1     1     0  9.9kb   4.9kb
green open .monitoring-kibana-7-2022.06.23 B7IrYQnWTqmpAXv6BAN0SA 1 1  3844     0    2mb 923.8kb

snapshot 생성

- postman tools

- curl 명령

curl -s -XPUT -H "Content-Type: application/json" 'https://localhost:9200/_snapshot/esbackup/efk-debug.test-20220622?wait_for_completion=true' -u "elastic:elastic1!" --cacert ../certs/ca/ca.crt -d '{
  "indices": "efk-debug.test-20220622",
  "ignore_unavailable": true,
  "include_global_state": true
}'
---output---
{"snapshot":{"snapshot":"efk-debug.test-20220622","uuid":"eKK_i2nkQRSt9ZXCwxr1Bg","repository":"esbackup","version_id":8020399,"version":"8.2.3","indices":[".kibana_task_manager_8.2.3_001",".apm-agent-configuration",".geoip_databases","efk-debug.test-20220622",".security-7",".kibana_security_session_1",".kibana_8.2.3_001",".apm-custom-link",".async-search"],"data_streams":[],"include_global_state":true,"state":"SUCCESS","start_time":"2022-06-23T05:53:18.848Z","start_time_in_millis":1655963598848,"end_time":"2022-06-23T05:53:21.249Z","end_time_in_millis":1655963601249,"duration_in_millis":2401,"failures":[],"shards":{"total":9,"failed":0,"successful":9},"feature_states":[{"feature_name":"kibana","indices":[".kibana_8.2.3_001",".apm-custom-link",".apm-agent-configuration",".kibana_task_manager_8.2.3_001",".kibana_security_session_1"]},{"feature_name":"geoip","indices":[".geoip_databases"]},{"feature_name":"async_search","indices":[".async-search"]},{"feature_name":"security","indices":[".security-7"]}]}}
728x90