index.asciidoc 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. [[snapshot-restore]]
  2. = Snapshot and restore
  3. A snapshot is a backup of a running {es} cluster. You can use snapshots to:
  4. * Regularly back up a cluster with no downtime
  5. * Recover data after deletion or a hardware failure
  6. * Transfer data between clusters
  7. * Reduce your storage costs by using <<searchable-snapshots,searchable
  8. snapshots>> in the cold and frozen data tiers
  9. [discrete]
  10. [[snapshot-workflow]]
  11. == The snapshot workflow
  12. {es} stores snapshots in an off-cluster storage location called a snapshot
  13. repository. Before you can take or restore snapshots, you must
  14. <<snapshots-register-repository,register a snapshot repository>> on the cluster.
  15. {es} supports several repository types with cloud storage options, including:
  16. * AWS S3
  17. * Google Cloud Storage (GCS)
  18. * Microsoft Azure
  19. After you register a snapshot repository, you can use
  20. <<automate-snapshots-slm,{slm} ({slm-init})>> to automatically take and manage
  21. snapshots. You can then <<snapshots-restore-snapshot,restore a snapshot>> to
  22. recover or transfer its data.
  23. [discrete]
  24. [[snapshot-contents]]
  25. == Snapshot contents
  26. By default, a snapshot of a cluster contains the cluster state, all regular data
  27. streams, and all regular indices. The cluster state includes:
  28. include::apis/restore-snapshot-api.asciidoc[tag=cluster-state-contents]
  29. You can also take snapshots of only specific data streams or indices in the
  30. cluster. A snapshot that includes a data stream or index automatically includes
  31. its aliases. When you restore a snapshot, you can choose whether to restore
  32. these aliases.
  33. Snapshots don't contain or back up:
  34. * Transient cluster settings
  35. * Registered snapshot repositories
  36. * Node configuration files
  37. * <<security-files,Security configuration files>>
  38. [discrete]
  39. [[feature-state]]
  40. === Feature states
  41. A feature state contains the indices and data streams used to store
  42. configurations, history, and other data for an Elastic feature, such as {es}
  43. security or {kib}.
  44. TIP: To retrieve a list of feature states, use the <<get-features-api,Features API>>.
  45. A feature state typically includes one or more <<system-indices,system indices
  46. or system data streams>>. It may also include regular indices and data streams
  47. used by the feature. For example, a feature state may include a regular index
  48. that contains the feature's execution history. Storing this history in a regular
  49. index lets you more easily search it.
  50. In {es} 8.0 and later versions, feature states are the only way to back up and
  51. restore system indices and system data streams.
  52. [discrete]
  53. [[how-snapshots-work]]
  54. == How snapshots work
  55. Snapshots are automatically deduplicated to save storage space and reduce network
  56. transfer costs. To back up an index, a snapshot makes a copy of the index's
  57. <<near-real-time,segments>> and stores them in the snapshot repository. Since
  58. segments are immutable, the snapshot only needs to copy any new segments created
  59. since the repository's last snapshot.
  60. Each snapshot is also logically independent. When you delete a snapshot, {es}
  61. only deletes the segments used exclusively by that snapshot. {es} doesn't delete
  62. segments used by other snapshots in the repository.
  63. [discrete]
  64. [[snapshots-shard-allocation]]
  65. === Snapshots and shard allocation
  66. A snapshot copies segments from an index's primary shards. When you start a
  67. snapshot, {es} immediately starts copying the segments of any available primary
  68. shards. If a shard is starting or relocating, {es} will wait for these processes
  69. to complete before copying the shard's segments. If one or more primary shards
  70. aren't available, the snapshot attempt fails.
  71. Once a snapshot begins copying a shard's segments, {es} won't move the shard to
  72. another node, even if rebalancing or shard allocation settings would typically
  73. trigger reallocation. {es} will only move the shard after the snapshot finishes
  74. copying the shard's data.
  75. [discrete]
  76. [[snapshot-start-stop-times]]
  77. === Snapshot start and stop times
  78. A snapshot doesn't represent a cluster at a precise point in time. Instead, each
  79. snapshot includes a start and end time. The snapshot represents a view of each
  80. shard's data at some point between these two times.
  81. [discrete]
  82. [[snapshot-restore-version-compatibility]]
  83. == Snapshot compatibility
  84. To restore a snapshot to a cluster, the versions for the snapshot, cluster, and
  85. any restored indices must be compatible.
  86. [discrete]
  87. [[snapshot-cluster-compatibility]]
  88. === Snapshot version compatibility
  89. You can't restore a snapshot to an earlier version of {es}. For example, you
  90. can't restore a snapshot taken in 7.6.0 to a cluster running 7.5.0.
  91. ifeval::["{release-state}"!="released"]
  92. [[snapshot-prerelease-build-compatibility]]
  93. NOTE: This documentation is for {es} version {version}, which is not yet
  94. released. The compatibility table above applies only to snapshots taken in a
  95. released version of {es}. If you're testing a pre-release build of {es} then you
  96. can still restore snapshots taken in earlier released builds as permitted by
  97. this compatibility table. You can also take snapshots using your pre-release
  98. build, and restore them using the same build. However once a pre-release build
  99. of {es} has written to a snapshot repository you must not use the same
  100. repository with other builds of {es}, even if the builds have the same version.
  101. Different pre-release builds of {es} may use different and incompatible
  102. repository layouts. If the repository layout is incompatible with the {es} build
  103. in use then taking and restoring snapshots may result in errors or may appear to
  104. succeed having silently lost some data. You should discard your repository
  105. before using a different build.
  106. endif::[]
  107. [discrete]
  108. [[snapshot-index-compatibility]]
  109. === Index compatibility
  110. Any index you restore from a snapshot must also be compatible with the current
  111. cluster's version. If you try to restore an index created in an incompatible
  112. version, the restore attempt will fail.
  113. include::cluster-index-compat.asciidoc[]
  114. You can't restore an index to an earlier version of {es}. For example, you can't
  115. restore an index created in 7.6.0 to a cluster running 7.5.0.
  116. A compatible snapshot can contain indices created in an older incompatible
  117. version. For example, a snapshot of a {prev-major-last} cluster can contain an
  118. index created in 6.8. Restoring the 6.8 index to an {minor-version} cluster
  119. fails unless you can use the <<archive-indices,archive functionality>>. Keep
  120. this in mind if you take a snapshot before upgrading a cluster.
  121. As a workaround, you can first restore the index to another cluster running the
  122. latest version of {es} that's compatible with both the index and your current
  123. cluster. You can then use <<reindex-from-remote,reindex-from-remote>> to rebuild
  124. the index on your current cluster. Reindex from remote is only possible if the
  125. index's <<mapping-source-field,`_source`>> is enabled.
  126. Reindexing from remote can take significantly longer than restoring a snapshot.
  127. Before you start, test the reindex from remote process with a subset of the data
  128. to estimate your time requirements.
  129. [discrete]
  130. [[snapshot-restore-warnings]]
  131. == Warnings
  132. [discrete]
  133. [[other-backup-methods]]
  134. === Other backup methods
  135. // tag::backup-warning[]
  136. **Taking a snapshot is the only reliable and supported way to back up a
  137. cluster.** You cannot back up an {es} cluster by making copies of the data
  138. directories of its nodes. There are no supported methods to restore any data
  139. from a filesystem-level backup. If you try to restore a cluster from such a
  140. backup, it may fail with reports of corruption or missing files or other data
  141. inconsistencies, or it may appear to have succeeded having silently lost some of
  142. your data.
  143. // end::backup-warning[]
  144. A copy of the data directories of a cluster's nodes does not work as a backup
  145. because it is not a consistent representation of their contents at a single
  146. point in time. You cannot fix this by shutting down nodes while making the
  147. copies, nor by taking atomic filesystem-level snapshots, because {es} has
  148. consistency requirements that span the whole cluster. You must use the built-in
  149. snapshot functionality for cluster backups.
  150. [discrete]
  151. [[snapshot-repository-contents]]
  152. === Repository contents
  153. **Don’t modify anything within the repository or run processes that might
  154. interfere with its contents.** If something other than {es} modifies the
  155. contents of the repository then future snapshot or restore operations may fail,
  156. reporting corruption or other data inconsistencies, or may appear to succeed
  157. having silently lost some of your data.
  158. You may however safely <<snapshots-repository-backup,restore a repository from a
  159. backup>> as long as
  160. . The repository is not registered with {es} while you are restoring its
  161. contents.
  162. . When you have finished restoring the repository its contents are exactly as
  163. they were when you took the backup.
  164. If you no longer need any of the snapshots in a repository, unregister it from
  165. {es} before deleting its contents from the underlying storage.
  166. Additionally, snapshots may contain security-sensitive information, which you
  167. may wish to <<cluster-state-snapshots,store in a dedicated repository>>.
  168. include::register-repository.asciidoc[]
  169. include::take-snapshot.asciidoc[]
  170. include::restore-snapshot.asciidoc[]
  171. include::../searchable-snapshots/index.asciidoc[]