恢复

编辑
actions:
  1:
    action: restore
    description: >-
      Restore all indices in the most recent snapshot with state SUCCESS.  Wait
      for the restore to complete before continuing.  Do not skip the repository
      filesystem access check.  Use the other options to define the index/shard
      settings for the restore.
    options:
      repository:
      # 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:
      wait_for_completion: True
      max_wait: 3600
      wait_interval: 10
    filters:
    - filtertype: state
      state: SUCCESS
      exclude:
    - filtertype: ...

空值和注释行将使用默认值(如有)。如果设置了某个设置,但未被给定的操作使用,则将被忽略。

此操作将从指定的 仓库 恢复索引,从应用过滤器标识的最新快照或 名称 指定的快照恢复。

恢复时重命名索引

编辑

您可以使用 rename_patternrename_replacement 选项在恢复时重命名索引。

actions:
  1:
    action: restore
    description: >-
      Restore all indices in the most recent snapshot with state SUCCESS.  Wait
      for the restore to complete before continuing.  Do not skip the repository
      filesystem access check.  Use the other options to define the index/shard
      settings for the restore.
    options:
      repository:
      # 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:
      rename_pattern: 'index(.+)'
      rename_replacement: 'restored_index$1'
      wait_for_completion: True
      max_wait: 3600
      wait_interval: 10
    filters:
    - filtertype: state
      state: SUCCESS
      exclude:
    - filtertype: ...

在此配置中,Elasticsearch 将捕获 index 后出现的任何内容,并将其放在 restored_index 后。例如,如果我正在恢复 index-2017.03.01,则生成的索引将重命名为 restored_index-2017.03.01

额外设置

编辑

extra_settings 选项允许添加额外的设置,例如索引设置。如何使用这些设置更改正在恢复的索引设置的一个示例可能是:

actions:
  1:
    action: restore
    description: >-
      Restore all indices in the most recent snapshot with state SUCCESS.  Wait
      for the restore to complete before continuing.  Do not skip the repository
      filesystem access check.  Use the other options to define the index/shard
      settings for the restore.
    options:
      repository:
      # 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:
      extra_settings:
        index_settings:
          number_of_replicas: 0
      wait_for_completion: True
      max_wait: 3600
      wait_interval: 10
    filters:
    - filtertype: state
      state: SUCCESS
      exclude:
    - filtertype: ...

在这种情况下,副本数量将应用于恢复的索引。

更多信息,请参见 官方 Elasticsearch 文档