1. snapshot

   indices 및 모든 cluster에 대해서 remote repository로 데이터 백업


2. snapshot repository 등록

1) 환경설정

elasticsearch.yml파일에

path.repo: ["/home/backup"] 등록


2) repository 등록

curl -XPUT 'http://localhost:9200/_snapshot/backup' -d '{

    "type": "fs",

    "settings": {

        "location": "/home/backup",

        "compress": true

    }

}'

   

3) repository 등록 확인

curl -XGET 'http://localhost:9200/_snapshot/backup?pretty'

curl -XGET 'http://localhost:9200/_snapshot?pretty'

curl -XGET 'http://localhost:9200/_snapshot/_all?pretty'


4) repository 상태 검증

curl -XGET 'http://localhost:9200/_snapshot/backup/_verify?pretty'


3. snapshot dump( 백업 진행 )

curl -XPUT 'http://localhost:9200/_snapshot/backup/snap_1?wait_for_completion=true' -d 

'{

"indices" : "test1, test2",

"ignore_unavailable" : "true",

"include_global_state" : false

}'


wait_for_completion : 작업이 완료될때까지 기달림

ignore_unavailable : index를 이용하지 못할때 그냥 ignore하고 계속 진행 (true)

include_global_state : snapshot에 cluster global status 저장되는거 방지(false)


* index snapshot은 incremental 방식이여서, 마지막 백업이후 변경된 부분만 추가


-- 백업 정보 확인

curl -XPUT 'http://localhost:9200/_snapshot/backup/snapshot_1'

curl -XPUT 'http://localhost:9200/_snapshot/backup/snapshot_*,other_snapshot'

curl -XPUT 'http://localhost:9200/_snapshot/backup/_all'


-- 현재 snapshot 정보

curl -XPUT 'http://localhost:9200/_snapshot/backup/_current'


4. snapshot dump 삭제

curl -XDELETE 'http://localhost:9200/_snapshot/backup/snapshot_1'

* snapshot이 만들어질때 delete 진행하면, 기존 dump는 중단되고 clean됨

  (오래 수행되는 dump를 중단할때 사용되기도 함)


5. restore snapshot


curl -XPOST 'http://localhost:9200/_snapshot/backup/snapshot_1/_restore'



curl -XPOST 'http://localhost:9200/_snapshot/backup/snapshot_1/_restore

{

  "indices": "index_1,index_2",              -- restore할 대상

  "ignore_unavailable": "true", 

  "include_global_state": false,

  "rename_pattern": "index_(.+)",          --  index로 시작하는          

  "rename_replacement": "restored_index_$1"   -- 해당 이름으로 변경

}'


-- restore시 index 생성 옵션 변경

curl -XPOST 'http://localhost:9200/_snapshot/backup/snapshot_1/_restore

{

  "indices": "index_1",

  "index_settings": {

    "index.number_of_replicas": 0

  },

  "ignore_index_settings": [

    "index.refresh_interval"

  ]

}'


* 기존 존재하는 인덱스에 복구시에는 같은 수에 shards를 가지고 있는지와 반드시 해당 인덱스를 closed 하고 난 다음 진행해야 함.



6. snapshot 모니터링

curl -XPOST 'http://localhost:9200/_snapshot/_status'    -- 전체

curl -XPOST 'http://localhost:9200/_snapshot/backup/_status'    -- backup repostory

curl -XPOST 'http://localhost:9200/_snapshot/backup/snap_1/_status'    -- snap_1 id





'NoSQL > Elasticsearch' 카테고리의 다른 글

kibana mavel 라이센스 update  (0) 2016.07.05
elasticsearch hw 및 config 설정  (0) 2016.06.21
elasticsearch monitoring  (0) 2016.06.15
elsticsearch 성능  (0) 2016.06.15
elasticsearch optimize api  (0) 2016.06.15

+ Recent posts