restore-snapshot.asciidoc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. [[snapshots-restore-snapshot]]
  2. == Restore a snapshot
  3. ////
  4. [source,console]
  5. -----------------------------------
  6. PUT /_snapshot/my_backup
  7. {
  8. "type": "fs",
  9. "settings": {
  10. "location": "my_backup_location"
  11. }
  12. }
  13. PUT /_snapshot/my_backup/snapshot_1?wait_for_completion=true
  14. -----------------------------------
  15. // TESTSETUP
  16. ////
  17. A snapshot can be restored using the following command:
  18. [source,console]
  19. -----------------------------------
  20. POST /_snapshot/my_backup/snapshot_1/_restore
  21. -----------------------------------
  22. By default, all data streams and indices in the snapshot are restored, but the cluster state is
  23. *not* restored. It's possible to select specific data streams or indices that should be restored as well
  24. as to allow the global cluster state from being restored by using `indices` and
  25. `include_global_state` options in the restore request body. The list
  26. supports <<multi-index,multi-target syntax>>.
  27. [WARNING]
  28. ====
  29. Each data stream requires a matching
  30. <<create-a-data-stream-template,index template>>. The stream uses this
  31. template to create new backing indices.
  32. When restoring a data stream, ensure a matching template exists for the stream.
  33. You can do this using one of the following methods:
  34. * Check for existing templates that match the stream. If no matching template
  35. exists, <<create-a-data-stream-template,create one>>.
  36. * Restore a global cluster state that includes a matching template for the
  37. stream.
  38. If no index template matches a data stream, the stream cannot
  39. <<manually-roll-over-a-data-stream,roll over>> or create new backing indices.
  40. ====
  41. The `rename_pattern`
  42. and `rename_replacement` options can be also used to rename data streams and indices on restore
  43. using regular expression that supports referencing the original text as
  44. explained
  45. http://docs.oracle.com/javase/6/docs/api/java/util/regex/Matcher.html#appendReplacement(java.lang.StringBuffer,%20java.lang.String)[here].
  46. If you rename a restored data stream, its backing indices are also
  47. renamed. For example, if you rename the `logs` data stream to `restored-logs`,
  48. the backing index `.ds-logs-000005` is renamed to `.ds-restored-logs-000005`.
  49. [WARNING]
  50. ====
  51. If you rename a restored stream, ensure an index template matches the new stream
  52. name. If no index template matches the stream, it cannot
  53. <<manually-roll-over-a-data-stream,roll over>> or create new backing indices.
  54. ====
  55. Set `include_aliases` to `false` to prevent aliases from being restored together
  56. with associated indices.
  57. [source,console]
  58. -----------------------------------
  59. POST /_snapshot/my_backup/snapshot_1/_restore
  60. {
  61. "indices": "data_stream_1,index_1,index_2",
  62. "ignore_unavailable": true,
  63. "include_global_state": false, <1>
  64. "rename_pattern": "index_(.+)",
  65. "rename_replacement": "restored_index_$1",
  66. "include_aliases": false
  67. }
  68. -----------------------------------
  69. // TEST[continued]
  70. <1> By default, `include_global_state` is `false`, meaning the snapshot's
  71. cluster state is not restored.
  72. +
  73. If `true`, the snapshot's persistent settings, index templates, ingest
  74. pipelines, and {ilm-init} policies are restored into the current cluster. This
  75. overwrites any existing cluster settings, templates, pipelines and {ilm-init}
  76. policies whose names match those in the snapshot.
  77. The restore operation can be performed on a functioning cluster. However, an
  78. existing index can be only restored if it's <<indices-open-close,closed>> and
  79. has the same number of shards as the index in the snapshot. The restore
  80. operation automatically opens restored indices if they were closed and creates
  81. new indices if they didn't exist in the cluster.
  82. If a data stream is restored, its backing indices are also restored. The restore
  83. operation automatically opens restored backing indices if they were closed.
  84. NOTE: You cannot restore a data stream if a stream with the same name already
  85. exists.
  86. In addition to entire data streams, you can restore only specific backing
  87. indices from a snapshot. However, restored backing indices are not automatically
  88. added to any existing data streams. For example, if only the `.ds-logs-000003`
  89. backing index is restored from a snapshot, it is not automatically added to the
  90. existing `logs` data stream.
  91. [float]
  92. === Partial restore
  93. By default, the entire restore operation will fail if one or more indices or backing indices participating in the operation don't have
  94. snapshots of all shards available. It can occur if some shards failed to snapshot for example. It is still possible to
  95. restore such indices by setting `partial` to `true`. Please note, that only successfully snapshotted shards will be
  96. restored in this case and all missing shards will be recreated empty.
  97. [float]
  98. === Changing index settings during restore
  99. Most of index settings can be overridden during the restore process. For example, the following command will restore
  100. the index `index_1` without creating any replicas while switching back to default refresh interval:
  101. [source,console]
  102. -----------------------------------
  103. POST /_snapshot/my_backup/snapshot_1/_restore
  104. {
  105. "indices": "index_1",
  106. "ignore_unavailable": true,
  107. "index_settings": {
  108. "index.number_of_replicas": 0
  109. },
  110. "ignore_index_settings": [
  111. "index.refresh_interval"
  112. ]
  113. }
  114. -----------------------------------
  115. // TEST[continued]
  116. Please note, that some settings such as `index.number_of_shards` cannot be changed during restore operation.
  117. For data streams, these index settings are applied to the restored backing
  118. indices.
  119. [IMPORTANT]
  120. ====
  121. The `index_settings` and `ignore_index_settings` parameters affect
  122. restored backing indices only. New backing indices created for a stream use the index
  123. settings specified in the stream's matching
  124. <<create-a-data-stream-template,index template>>.
  125. If you change index settings during a restore, we recommend you make similar
  126. changes in the stream's matching index template. This ensures new backing
  127. indices created for the stream use the same index settings.
  128. ====
  129. [float]
  130. === Restoring to a different cluster
  131. The information stored in a snapshot is not tied to a particular cluster or a cluster name. Therefore it's possible to
  132. restore a snapshot made from one cluster into another cluster. All that is required is registering the repository
  133. containing the snapshot in the new cluster and starting the restore process. The new cluster doesn't have to have the
  134. same size or topology. However, the version of the new cluster should be the same or newer (only 1 major version newer) than the cluster that was used to create the snapshot. For example, you can restore a 1.x snapshot to a 2.x cluster, but not a 1.x snapshot to a 5.x cluster.
  135. If the new cluster has a smaller size additional considerations should be made. First of all it's necessary to make sure
  136. that new cluster have enough capacity to store all data streams and indices in the snapshot. It's possible to change index settings
  137. during restore to reduce the number of replicas, which can help with restoring snapshots into smaller cluster. It's also
  138. possible to select only subset of the data streams or indices using the `indices` parameter.
  139. If indices or backing indices in the original cluster were assigned to particular nodes using
  140. <<shard-allocation-filtering,shard allocation filtering>>, the same rules will be enforced in the new cluster. Therefore
  141. if the new cluster doesn't contain nodes with appropriate attributes that a restored index can be allocated on, such
  142. index will not be successfully restored unless these index allocation settings are changed during restore operation.
  143. The restore operation also checks that restored persistent settings are compatible with the current cluster to avoid accidentally
  144. restoring incompatible settings. If you need to restore a snapshot with incompatible persistent settings, try restoring it without
  145. the global cluster state.