restore-snapshot.asciidoc 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. [[snapshots-restore-snapshot]]
  2. == Restore indices from a snapshot
  3. ++++
  4. <titleabbrev>Restore a snapshot</titleabbrev>
  5. ++++
  6. ////
  7. [source,console]
  8. -----------------------------------
  9. PUT /_snapshot/my_backup
  10. {
  11. "type": "fs",
  12. "settings": {
  13. "location": "my_backup_location"
  14. }
  15. }
  16. PUT /_snapshot/my_backup/snapshot_1?wait_for_completion=true
  17. -----------------------------------
  18. // TESTSETUP
  19. ////
  20. A snapshot can be restored using the following command:
  21. [source,console]
  22. -----------------------------------
  23. POST /_snapshot/my_backup/snapshot_1/_restore
  24. -----------------------------------
  25. By default, all indices in the snapshot are restored, and the cluster state is
  26. *not* restored. It's possible to select indices that should be restored as well
  27. as to allow the global cluster state from being restored by using `indices` and
  28. `include_global_state` options in the restore request body. The list of indices
  29. supports <<multi-index,multi index syntax>>. The `rename_pattern`
  30. and `rename_replacement` options can be also used to rename indices on restore
  31. using regular expression that supports referencing the original text as
  32. explained
  33. http://docs.oracle.com/javase/6/docs/api/java/util/regex/Matcher.html#appendReplacement(java.lang.StringBuffer,%20java.lang.String)[here].
  34. Set `include_aliases` to `false` to prevent aliases from being restored together
  35. with associated indices.
  36. [source,console]
  37. -----------------------------------
  38. POST /_snapshot/my_backup/snapshot_1/_restore
  39. {
  40. "indices": "index_1,index_2",
  41. "ignore_unavailable": true,
  42. "include_global_state": false, <1>
  43. "rename_pattern": "index_(.+)",
  44. "rename_replacement": "restored_index_$1",
  45. "include_aliases": false
  46. }
  47. -----------------------------------
  48. // TEST[continued]
  49. <1> By default, `include_global_state` is `false`, meaning the snapshot's
  50. cluster state is not restored.
  51. +
  52. If `true`, the snapshot's persistent settings, index templates, ingest
  53. pipelines, and {ilm-init} policies are restored into the current cluster. This
  54. overwrites any existing cluster settings, templates, pipelines and {ilm-init}
  55. policies whose names match those in the snapshot.
  56. The restore operation can be performed on a functioning cluster. However, an
  57. existing index can be only restored if it's <<indices-open-close,closed>> and
  58. has the same number of shards as the index in the snapshot. The restore
  59. operation automatically opens restored indices if they were closed and creates
  60. new indices if they didn't exist in the cluster.
  61. [float]
  62. === Partial restore
  63. By default, the entire restore operation will fail if one or more indices participating in the operation don't have
  64. snapshots of all shards available. It can occur if some shards failed to snapshot for example. It is still possible to
  65. restore such indices by setting `partial` to `true`. Please note, that only successfully snapshotted shards will be
  66. restored in this case and all missing shards will be recreated empty.
  67. [float]
  68. === Changing index settings during restore
  69. Most of index settings can be overridden during the restore process. For example, the following command will restore
  70. the index `index_1` without creating any replicas while switching back to default refresh interval:
  71. [source,console]
  72. -----------------------------------
  73. POST /_snapshot/my_backup/snapshot_1/_restore
  74. {
  75. "indices": "index_1",
  76. "ignore_unavailable": true,
  77. "index_settings": {
  78. "index.number_of_replicas": 0
  79. },
  80. "ignore_index_settings": [
  81. "index.refresh_interval"
  82. ]
  83. }
  84. -----------------------------------
  85. // TEST[continued]
  86. Please note, that some settings such as `index.number_of_shards` cannot be changed during restore operation.
  87. [float]
  88. === Restoring to a different cluster
  89. The information stored in a snapshot is not tied to a particular cluster or a cluster name. Therefore it's possible to
  90. restore a snapshot made from one cluster into another cluster. All that is required is registering the repository
  91. containing the snapshot in the new cluster and starting the restore process. The new cluster doesn't have to have the
  92. 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.
  93. If the new cluster has a smaller size additional considerations should be made. First of all it's necessary to make sure
  94. that new cluster have enough capacity to store all indices in the snapshot. It's possible to change indices settings
  95. during restore to reduce the number of replicas, which can help with restoring snapshots into smaller cluster. It's also
  96. possible to select only subset of the indices using the `indices` parameter.
  97. If indices in the original cluster were assigned to particular nodes using
  98. <<shard-allocation-filtering,shard allocation filtering>>, the same rules will be enforced in the new cluster. Therefore
  99. if the new cluster doesn't contain nodes with appropriate attributes that a restored index can be allocated on, such
  100. index will not be successfully restored unless these index allocation settings are changed during restore operation.
  101. The restore operation also checks that restored persistent settings are compatible with the current cluster to avoid accidentally
  102. restoring incompatible settings. If you need to restore a snapshot with incompatible persistent settings, try restoring it without
  103. the global cluster state.
  104. [float]
  105. === Snapshot status
  106. A list of currently running snapshots with their detailed status information can be obtained using the following command:
  107. [source,console]
  108. -----------------------------------
  109. GET /_snapshot/_status
  110. -----------------------------------
  111. // TEST[continued]
  112. In this format, the command will return information about all currently running snapshots. By specifying a repository name, it's possible
  113. to limit the results to a particular repository:
  114. [source,console]
  115. -----------------------------------
  116. GET /_snapshot/my_backup/_status
  117. -----------------------------------
  118. // TEST[continued]
  119. If both repository name and snapshot id are specified, this command will return detailed status information for the given snapshot even
  120. if it's not currently running:
  121. [source,console]
  122. -----------------------------------
  123. GET /_snapshot/my_backup/snapshot_1/_status
  124. -----------------------------------
  125. // TEST[continued]
  126. The output looks similar to the following:
  127. [source,console-result]
  128. --------------------------------------------------
  129. {
  130. "snapshots": [
  131. {
  132. "snapshot": "snapshot_1",
  133. "repository": "my_backup",
  134. "uuid": "XuBo4l4ISYiVg0nYUen9zg",
  135. "state": "SUCCESS",
  136. "include_global_state": true,
  137. "shards_stats": {
  138. "initializing": 0,
  139. "started": 0,
  140. "finalizing": 0,
  141. "done": 5,
  142. "failed": 0,
  143. "total": 5
  144. },
  145. "stats": {
  146. "incremental": {
  147. "file_count": 8,
  148. "size_in_bytes": 4704
  149. },
  150. "processed": {
  151. "file_count": 7,
  152. "size_in_bytes": 4254
  153. },
  154. "total": {
  155. "file_count": 8,
  156. "size_in_bytes": 4704
  157. },
  158. "start_time_in_millis": 1526280280355,
  159. "time_in_millis": 358
  160. }
  161. }
  162. ]
  163. }
  164. --------------------------------------------------
  165. // TESTRESPONSE[skip: No snapshot status to validate.]
  166. The output is composed of different sections. The `stats` sub-object provides details on the number and size of files that were
  167. snapshotted. As snapshots are incremental, copying only the Lucene segments that are not already in the repository,
  168. the `stats` object contains a `total` section for all the files that are referenced by the snapshot, as well as an `incremental` section
  169. for those files that actually needed to be copied over as part of the incremental snapshotting. In case of a snapshot that's still
  170. in progress, there's also a `processed` section that contains information about the files that are in the process of being copied.
  171. Multiple ids are also supported:
  172. [source,console]
  173. -----------------------------------
  174. GET /_snapshot/my_backup/snapshot_1,snapshot_2/_status
  175. -----------------------------------
  176. // TEST[skip: no snapshot_2 to get]