index.asciidoc 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. [discrete]
  38. [[feature-state]]
  39. === Feature states
  40. A feature state contains the indices and data streams used to store
  41. configurations, history, and other data for an Elastic feature, such as {es}
  42. security or {kib}.
  43. A feature state typically includes one or more <<system-indices,system indices
  44. or system data streams>>. It may also include regular indices and data streams
  45. used by the feature. For example, a feature state may include a regular index
  46. that contains the feature's execution history. Storing this history in a regular
  47. index lets you more easily search it.
  48. In {es} 8.0 and later versions, feature states are the only way to back up and
  49. restore system indices and system data streams.
  50. [discrete]
  51. [[how-snapshots-work]]
  52. == How snapshots work
  53. Snapshots are automatically deduplicated to save storage space and reduce network
  54. transfer costs. To back up an index, a snapshot makes a copy of the index's
  55. <<near-real-time,segments>> and stores them in the snapshot repository. Since
  56. segments are immutable, the snapshot only needs to copy any new segments created
  57. since the repository's last snapshot.
  58. Each snapshot is also logically independent. When you delete a snapshot, {es}
  59. only deletes the segments used exclusively by that snapshot. {es} doesn't delete
  60. segments used by other snapshots in the repository.
  61. [discrete]
  62. [[snapshots-shard-allocation]]
  63. === Snapshots and shard allocation
  64. A snapshot copies segments from an index's primary shards. When you start a
  65. snapshot, {es} immediately starts copying the segments of any available primary
  66. shards. If a shard is starting or relocating, {es} will wait for these processes
  67. to complete before copying the shard's segments. If one or more primary shards
  68. aren't available, the snapshot attempt fails.
  69. Once a snapshot begins copying a shard's segments, {es} won't move the shard to
  70. another node, even if rebalancing or shard allocation settings would typically
  71. trigger reallocation. {es} will only move the shard after the snapshot finishes
  72. copying the shard's data.
  73. [discrete]
  74. [[snapshot-start-stop-times]]
  75. === Snapshot start and stop times
  76. A snapshot doesn't represent a cluster at a precise point in time. Instead, each
  77. snapshot includes a start and end time. The snapshot represents a view of each
  78. shard's data at some point between these two times.
  79. [discrete]
  80. [[snapshot-restore-version-compatibility]]
  81. == Snapshot compatibility
  82. To restore a snapshot to a cluster, the versions for the snapshot, cluster, and
  83. any restored indices must be compatible.
  84. [discrete]
  85. [[snapshot-cluster-compatibility]]
  86. === Snapshot version compatibility
  87. include::snapshot-vers-compat.asciidoc[]
  88. You can't restore a snapshot to an earlier version of {es}. For example, you
  89. can't restore a snapshot taken in 7.6.0 to a cluster running 7.5.0.
  90. ifeval::["{release-state}"!="released"]
  91. [[snapshot-prerelease-build-compatibility]]
  92. NOTE: This documentation is for {es} version {version}, which is not yet
  93. released. The compatibility table above applies only to snapshots taken in a
  94. released version of {es}. If you're testing a pre-release build of {es} then you
  95. can still restore snapshots taken in earlier released builds as permitted by
  96. this compatibility table. You can also take snapshots using your pre-release
  97. build, and restore them using the same build. However once a pre-release build
  98. of {es} has written to a snapshot repository you must not use the same
  99. repository with other builds of {es}, even if the builds have the same version.
  100. Different pre-release builds of {es} may use different and incompatible
  101. repository layouts. If the repository layout is incompatible with the {es} build
  102. in use then taking and restoring snapshots may result in errors or may appear to
  103. succeed having silently lost some data. You should discard your repository
  104. before using a different build.
  105. endif::[]
  106. [discrete]
  107. [[snapshot-index-compatibility]]
  108. === Index compatibility
  109. Any index you restore from a snapshot must also be compatible with the current
  110. cluster's version. If you try to restore an index created in an incompatible
  111. version, the restore attempt will fail.
  112. include::cluster-index-compat.asciidoc[]
  113. You can't restore an index to an earlier version of {es}. For example, you can't
  114. restore an index created in 7.6.0 to a cluster running 7.5.0.
  115. A compatible snapshot can contain indices created in an incompatible version.
  116. For example, a snapshot of a {prev-major-last} cluster can contain an index
  117. created in 6.8. If you try to restore the 6.8 index to an {minor-version}
  118. cluster, the restore attempt will fail. Keep this in mind if you take a snapshot
  119. before upgrading a cluster.
  120. As a workaround, you can first restore the index to another cluster running the
  121. latest version of {es} that's compatible with both the index and your current
  122. cluster. You can then use <<reindex-from-remote,reindex-from-remote>> to rebuild
  123. the index on your current cluster. Reindex from remote is only possible if the
  124. index's <<mapping-source-field,`_source`>> is enabled.
  125. Reindexing from remote can take significantly longer than restoring a snapshot.
  126. Before you start, test the reindex from remote process with a subset of the data
  127. to estimate your time requirements.
  128. [discrete]
  129. [[snapshot-restore-warnings]]
  130. == Warnings
  131. [discrete]
  132. [[other-backup-methods]]
  133. === Other backup methods
  134. // tag::backup-warning[]
  135. **Taking a snapshot is the only reliable and supported way to back up a
  136. cluster.** You cannot back up an {es} cluster by making copies of the data
  137. directories of its nodes. There are no supported methods to restore any data
  138. from a filesystem-level backup. If you try to restore a cluster from such a
  139. backup, it may fail with reports of corruption or missing files or other data
  140. inconsistencies, or it may appear to have succeeded having silently lost some of
  141. your data.
  142. // end::backup-warning[]
  143. A copy of the data directories of a cluster's nodes does not work as a backup
  144. because it is not a consistent representation of their contents at a single
  145. point in time. You cannot fix this by shutting down nodes while making the
  146. copies, nor by taking atomic filesystem-level snapshots, because {es} has
  147. consistency requirements that span the whole cluster. You must use the built-in
  148. snapshot functionality for cluster backups.
  149. [discrete]
  150. [[snapshot-repository-contents]]
  151. === Repository contents
  152. **Don’t modify anything within the repository or run processes that might
  153. interfere with its contents.** If something other than {es} modifies the
  154. contents of the repository then future snapshot or restore operations may fail,
  155. reporting corruption or other data inconsistencies, or may appear to succeed
  156. having silently lost some of your data.
  157. You may however safely <<snapshots-repository-backup,restore a repository from
  158. a backup>> as long as
  159. . The repository is not registered with {es} while you are restoring its
  160. contents.
  161. . When you have finished restoring the repository its contents are exactly as
  162. they were when you took the backup.
  163. include::register-repository.asciidoc[]
  164. include::take-snapshot.asciidoc[]
  165. include::restore-snapshot.asciidoc[]
  166. include::../searchable-snapshots/index.asciidoc[]