Is it possible to take snapshot and restore with elasticsearch-curator without loosing the updates in the destination index?

553 views Asked by At

I am able to run the curator to take the snapshot from the source index and restore the same snapshot in the destination index. But all the updations that I did on the destination index are lost after the next snapshot and restore action.

Is it possible to specify not to overwrite the updations of the destination index?

source index: test_index

destination index: dest_test_index

snapshot-action.yml file

actions:
  1:
    action: snapshot
    description: Snapshot selected indices to 'repository' with the snapshot name or name pattern in 'name'.  Use all other options as assigned
    options:
      repository: esbackup
      name:
      wait_for_completion: True
      max_wait: 3600
      wait_interval: 10
    filters:
    - filtertype: pattern
      kind: regex
      value: '^(test_index)$'
      exclude:

restore-action.yml file

actions:
  1:
    action: create_index
    description: "Create the temporary index with dest_index_v2 name"
    options:
      name: dest_index_v2
  2:
    action: close
    description: >-
      Close index dest_indiex_v2.
    options:
      ignore_empty_list: True
      skip_flush: False
      delete_aliases: False
      ignore_sync_failures: True
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: dest_index_v2
  3:
    action: restore
    description: >-
      Restore test_index from the most recent snapshot in temp index dest_index_v2.
    options:
      repository: esbackup
      # If name is blank, the most recent snapshot by age will be selected
      name:
      # If indices is blank, all indices in the snapshot will be restored
      indices: ['test_index']
      rename_pattern: test_index
      rename_replacement: dest_index_v2
      wait_for_completion: True
      max_wait: 3600
      wait_interval: 10
    filters:
    - filtertype: none
  4:
    action: open
    description: >-
      Open index pattern dest_index_v2.
    options:
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: dest_index_v2
      exclude:
  5:
    description: "Reindex dest_index_v2 into dest_test_index"
    action: reindex
    options:
      wait_interval: 9
      max_wait: -1
      request_body:
        source:
          index: dest_index_v2
        dest:
          index: dest_test_index
    filters:
    - filtertype: none
  6:
    action: delete_indices
    description: >-
      Delete index dest_index_v2. Ignore the error if the filter does not result in an
      actionable list of indices (ignore_empty_list) and exit cleanly.
    options:
      ignore_empty_list: False
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: dest_index_v2
1

There are 1 answers

1
piyush daftary On

If you are looking for some elasticsearch setting which will merge in updated destination index with the source index(which you are restoring from snapshot), then the short answer is NO.

You can write custom code to perform following operation to make sure destination index update is not lost.

  1. Restore source index(test_index) to a temporary index in the cluster , lets call this index as temp_index
  2. Retrieve documents from temp_index and insert in destination index (dest_test_index) with op_type=create Operation type create will make sure that the index operation will fail if a document by that id already exists in the index. You can refer to documentation here

Hope this solves your purpose.