register-repository.asciidoc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. [[snapshots-register-repository]]
  2. == Register a snapshot repository
  3. ++++
  4. <titleabbrev>Register a repository</titleabbrev>
  5. ++++
  6. This guide shows you how to register a snapshot repository. A snapshot
  7. repository is an off-cluster storage location for your snapshots. You must
  8. register a repository before you can take or restore snapshots.
  9. In this guide, you’ll learn how to:
  10. * Register a snapshot repository
  11. * Verify that a repository is functional
  12. * Clean up a repository to remove unneeded files
  13. [discrete]
  14. [[snapshot-repo-prereqs]]
  15. === Prerequisites
  16. // tag::kib-snapshot-prereqs[]
  17. * To use {kib}'s **Snapshot and Restore** feature, you must have the following
  18. permissions:
  19. ** <<privileges-list-cluster,Cluster privileges>>: `monitor`, `manage_slm`,
  20. `cluster:admin/snapshot`, and `cluster:admin/repository`
  21. ** <<privileges-list-indices,Index privilege>>: `all` on the `monitor` index
  22. // end::kib-snapshot-prereqs[]
  23. include::apis/put-repo-api.asciidoc[tag=put-repo-api-prereqs]
  24. [discrete]
  25. [[snapshot-repo-considerations]]
  26. === Considerations
  27. When registering a snapshot repository, keep the following in mind:
  28. * Each snapshot repository is separate and independent. {es} doesn't share
  29. data between repositories.
  30. * {blank}
  31. +
  32. --
  33. // tag::multi-cluster-repo[]
  34. If you register the same snapshot repository with multiple clusters, only one
  35. cluster should have write access to the repository. On other clusters, register
  36. the repository as read-only.
  37. This prevents multiple clusters from writing to the repository at the same time
  38. and corrupting the repository’s contents. It also prevents {es} from caching the
  39. repository's contents, which means that changes made by other clusters will
  40. become visible straight away.
  41. // end::multi-cluster-repo[]
  42. --
  43. * Use a different snapshot repository for each major version of {es}. Mixing
  44. snapshots from different major versions can corrupt a repository’s contents.
  45. [discrete]
  46. [[manage-snapshot-repos]]
  47. === Manage snapshot repositories
  48. You can register and manage snapshot repositories in two ways:
  49. * {kib}'s **Snapshot and Restore** feature
  50. * {es}'s <<snapshot-restore-repo-apis,snapshot repository management APIs>>
  51. To manage repositories in {kib}, go to the main menu and click **Stack
  52. Management** > **Snapshot and Restore** > **Repositories**. To register a
  53. snapshot repository, click **Register repository**.
  54. You can also register a repository using the <<put-snapshot-repo-api,Create
  55. snapshot repository API>>.
  56. [discrete]
  57. [[snapshot-repo-types]]
  58. === Snapshot repository types
  59. Supported snapshot repository types vary based on your deployment type:
  60. * <<ess-repo-types>>
  61. * <<self-managed-repo-types>>
  62. [discrete]
  63. [[ess-repo-types]]
  64. ==== {ess} repository types
  65. {ess-trial}[{ess} deployments] automatically register the
  66. {cloud}/ec-snapshot-restore.html[`found-snapshots`] repository. {ess} uses this
  67. repository and the `cloud-snapshot-policy` to take periodic snapshots of your
  68. cluster. You can also use the `found-snapshots` repository for your own
  69. <<automate-snapshots-slm,{slm-init} policies>> or to store searchable snapshots.
  70. The `found-snapshots` repository is specific to each deployment. However, you
  71. can restore snapshots from another deployment's `found-snapshots` repository if
  72. the deployments are under the same account and in the same region. See
  73. {cloud}/ec_share_a_repository_across_clusters.html[Share a repository across
  74. clusters].
  75. {ess} deployments also support the following repository types:
  76. * {cloud}/ec-azure-snapshotting.html[Azure]
  77. * {cloud}/ec-gcs-snapshotting.html[Google Cloud Storage]
  78. * {cloud}/ec-aws-custom-repository.html[AWS S3]
  79. * <<snapshots-source-only-repository,Source-only>>
  80. [discrete]
  81. [[self-managed-repo-types]]
  82. ==== Self-managed repository types
  83. If you run {es} on your own hardware, you can use the following built-in
  84. snapshot repository types:
  85. * <<repository-azure,Azure>>
  86. * <<repository-gcs,Google Cloud Storage>>
  87. * <<repository-s3,AWS S3>>
  88. * <<snapshots-filesystem-repository,Shared file system>>
  89. * <<snapshots-read-only-repository,Read-only URL>>
  90. * <<snapshots-source-only-repository,Source-only>>
  91. [[snapshots-repository-plugins]]
  92. Other repository types are available through official plugins:
  93. * {plugins}/repository-hdfs.html[Hadoop Distributed File System (HDFS)]
  94. You can also use alternative implementations of these repository types, such as
  95. MinIO, as long as they're compatible. To verify a repository's compatibility,
  96. see <<snapshots-repository-verification>>.
  97. [discrete]
  98. [[snapshots-repository-verification]]
  99. === Verify a repository
  100. When you register a snapshot repository, {es} automatically verifies that the
  101. repository is available and functional on all master and data nodes.
  102. To disable this verification, set the <<put-snapshot-repo-api,create snapshot
  103. repository API>>'s `verify` query parameter to `false`. You can't disable
  104. repository verification in {kib}.
  105. [source,console]
  106. ----
  107. PUT _snapshot/my_unverified_backup?verify=false
  108. {
  109. "type": "fs",
  110. "settings": {
  111. "location": "my_unverified_backup_location"
  112. }
  113. }
  114. ----
  115. // TEST[setup:setup-repository]
  116. // TEST[s/my_unverified_backup_location/my_repository/]
  117. If wanted, you can manually run the repository verification check. To verify a
  118. repository in {kib}, go to the **Repositories** list page and click the name of
  119. a repository. Then click **Verify repository**. You can also use the
  120. <<verify-snapshot-repo-api,verify snapshot repository API>>.
  121. [source,console]
  122. ----
  123. POST _snapshot/my_unverified_backup/_verify
  124. ----
  125. // TEST[continued]
  126. // TEST[s/my_unverified_backup_location/my_repository/]
  127. If successful, the request returns a list of nodes used to verify the
  128. repository. If verification fails, the request returns an error.
  129. You can test a repository more thoroughly using the
  130. <<repo-analysis-api,repository analysis API>>.
  131. [discrete]
  132. [[snapshots-repository-cleanup]]
  133. === Clean up a repository
  134. Repositories can over time accumulate data that is not referenced by any existing snapshot. This is a result of the data safety guarantees
  135. the snapshot functionality provides in failure scenarios during snapshot creation and the decentralized nature of the snapshot creation
  136. process. This unreferenced data does in no way negatively impact the performance or safety of a snapshot repository but leads to higher
  137. than necessary storage use. To remove this unreferenced data, you can run a cleanup operation on the repository. This will
  138. trigger a complete accounting of the repository's contents and delete any unreferenced data.
  139. To run the repository cleanup operation in {kib}, go to the **Repositories**
  140. list page and click the name of a repository. Then click **Clean up
  141. repository**.
  142. You can also use the <<clean-up-snapshot-repo-api,clean up snapshot repository
  143. API>>.
  144. [source,console]
  145. ----
  146. POST _snapshot/my_repository/_cleanup
  147. ----
  148. // TEST[setup:setup-snapshots]
  149. The API returns:
  150. [source,console-result]
  151. ----
  152. {
  153. "results": {
  154. "deleted_bytes": 20,
  155. "deleted_blobs": 5
  156. }
  157. }
  158. ----
  159. // TESTRESPONSE[s/"deleted_bytes": 20/"deleted_bytes": $body.results.deleted_bytes/]
  160. // TESTRESPONSE[s/"deleted_blobs": 5/"deleted_blobs": $body.results.deleted_bytes/]
  161. Depending on the concrete repository implementation the numbers shown for bytes free as well as the number of blobs removed will either
  162. be an approximation or an exact result. Any non-zero value for the number of blobs removed implies that unreferenced blobs were found and
  163. subsequently cleaned up.
  164. Please note that most of the cleanup operations executed by this endpoint are automatically executed when deleting any snapshot from a
  165. repository. If you regularly delete snapshots, you will in most cases not get any or only minor space savings from using this functionality
  166. and should lower your frequency of invoking it accordingly.
  167. [discrete]
  168. [[snapshots-repository-backup]]
  169. === Back up a repository
  170. You may wish to make an independent backup of your repository, for instance so
  171. that you have an archive copy of its contents that you can use to recreate the
  172. repository in its current state at a later date.
  173. You must ensure that {es} does not write to the repository while you are taking
  174. the backup of its contents. You can do this by unregistering it, or registering
  175. it with `readonly: true`, on all your clusters. If {es} writes any data to the
  176. repository during the backup then the contents of the backup may not be
  177. consistent and it may not be possible to recover any data from it in future.
  178. Alternatively, if your repository supports it, you may take an atomic snapshot
  179. of the underlying filesystem and then take a backup of this filesystem
  180. snapshot. It is very important that the filesystem snapshot is taken
  181. atomically.
  182. WARNING: You cannot use filesystem snapshots of individual nodes as a backup
  183. mechanism. You must use the {es} snapshot and restore feature to copy the
  184. cluster contents to a separate repository. Then, if desired, you can take a
  185. filesystem snapshot of this repository.
  186. When restoring a repository from a backup, you must not register the repository
  187. with {es} until the repository contents are fully restored. If you alter the
  188. contents of a repository while it is registered with {es} then the repository
  189. may become unreadable or may silently lose some of its contents.
  190. include::repository-azure.asciidoc[]
  191. include::repository-gcs.asciidoc[]
  192. include::repository-s3.asciidoc[]
  193. include::repository-shared-file-system.asciidoc[]
  194. include::repository-read-only-url.asciidoc[]
  195. include::repository-source-only.asciidoc[]