restore-snapshot.asciidoc 8.0 KB

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