put-repo-api.asciidoc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. [[put-snapshot-repo-api]]
  2. === Create or update snapshot repository API
  3. ++++
  4. <titleabbrev>Create or update snapshot repository</titleabbrev>
  5. ++++
  6. Registers or updates a <<snapshots-register-repository,snapshot repository>>.
  7. [source,console]
  8. ----
  9. PUT /_snapshot/my_repository
  10. {
  11. "type": "fs",
  12. "settings": {
  13. "location": "my_backup_location"
  14. }
  15. }
  16. ----
  17. [[put-snapshot-repo-api-request]]
  18. ==== {api-request-title}
  19. `PUT /_snapshot/<repository>`
  20. `POST /_snapshot/<repository>`
  21. [[put-snapshot-repo-api-prereqs]]
  22. ==== {api-prereq-title}
  23. * If the {es} {security-features} are enabled, you must have the `manage`
  24. <<privileges-list-cluster,cluster privilege>> to use this API.
  25. [[put-snapshot-repo-api-desc]]
  26. ==== {api-description-title}
  27. A snapshot repository must be registered before you can perform
  28. <<snapshot-restore,snapshot and restore>> operations. You can use the put
  29. snapshot repository API to register new repositories and update existing ones.
  30. See <<snapshots-register-repository>>.
  31. TIP: Because snapshot formats can change between major versions of
  32. {es}, we recommend registering a new snapshot repository for each major version.
  33. See <<snapshot-restore-version-compatibility>>.
  34. [[put-snapshot-repo-api-path-params]]
  35. ==== {api-path-parms-title}
  36. `<repository>`::
  37. (Required, string)
  38. Name of the snapshot repository to register or update.
  39. [[put-snapshot-repo-api-query-params]]
  40. ==== {api-query-parms-title}
  41. IMPORTANT: Several options for this API can be specified using a query parameter
  42. or a request body parameter. If both parameters are specified, only the query
  43. parameter is used.
  44. `master_timeout`::
  45. (Optional, <<time-units, time units>>) Specifies the period of time to wait for
  46. a connection to the master node. If no response is received before the timeout
  47. expires, the request fails and returns an error. Defaults to `30s`.
  48. `timeout`::
  49. (Optional, <<time-units, time units>>) Specifies the period of time to wait for
  50. a response. If no response is received before the timeout expires, the request
  51. fails and returns an error. Defaults to `30s`.
  52. `verify`::
  53. (Optional, Boolean)
  54. If `true`, the request verifies the repository is functional on all master and
  55. data nodes in the cluster. If `false`, this verification is skipped. Defaults to
  56. `true`.
  57. +
  58. You can manually perform this verification using the
  59. <<verify-snapshot-repo-api,verify snapshot repository API>>.
  60. [role="child_attributes"]
  61. [[put-snapshot-repo-api-request-body]]
  62. ==== {api-request-body-title}
  63. [[put-snapshot-repo-api-request-type]]
  64. `type`::
  65. +
  66. --
  67. (Required, string)
  68. Repository type.
  69. .Valid values for `type`
  70. [%collapsible%open]
  71. ====
  72. `fs`::
  73. Shared file system repository. Repositories of this type use a shared file
  74. system to store snapshots. This file system must accessible to all master and
  75. data nodes in the cluster.
  76. +
  77. IMPORTANT: To register a shared file system repository, you must mount the same
  78. shared filesystem to the same location on all master and data nodes. This
  79. location must be registered in the `path.repo` setting on all master and data
  80. nodes in the cluster.
  81. +
  82. See <<snapshots-filesystem-repository>>.
  83. [xpack]#`source`#::
  84. Source-only repository. You can use source-only repositories to create minimal,
  85. source-only snapshots that take up to 50% less space on disk.
  86. +
  87. Source-only snapshots are only supported if the <<mapping-source-field,`_source`
  88. field>> is enabled and no
  89. <<source-filtering,source-filtering>> is applied.
  90. +
  91. WARNING: Source-only snapshots contain stored fields and index metadata. They do
  92. not include index or doc values structures and are not searchable when restored.
  93. After restoring a source-only snapshot, you must <<docs-reindex,reindex>> the
  94. data into a new index.
  95. +
  96. See <<snapshots-source-only-repository>>.
  97. `url`::
  98. URL repository. Repositories of this type are read-only
  99. for the cluster. This means the cluster can retrieve or restore snapshots from
  100. the repository but cannot write or create snapshots in it.
  101. +
  102. You can use URL repositories as an alternative way to give a cluster read-only
  103. access to a shared file system (`fs`) repository.
  104. +
  105. See <<snapshots-read-only-repository>>.
  106. ====
  107. More repository types are available through these official
  108. plugins:
  109. * {plugins}/repository-s3.html[repository-s3] for S3 repository support
  110. * {plugins}/repository-hdfs.html[repository-hdfs] for HDFS repository support in
  111. Hadoop environments
  112. * {plugins}/repository-azure.html[repository-azure] for Azure storage
  113. repositories
  114. * {plugins}/repository-gcs.html[repository-gcs] for Google Cloud Storage
  115. repositories
  116. --
  117. [[put-snapshot-repo-api-settings-param]]
  118. `settings`::
  119. +
  120. --
  121. (Required, object)
  122. Contains settings for the repository.
  123. The following `settings` properties are valid for all repository types:
  124. .Properties of `settings`
  125. [%collapsible%open]
  126. ====
  127. `chunk_size`::
  128. (Optional, <<byte-units,byte value>>)
  129. Maximum size of files in snapshots. In snapshots, files larger than this are
  130. broken down into chunks of this size or smaller. Defaults to `null` (unlimited
  131. file size).
  132. `compress`::
  133. (Optional, Boolean)
  134. If `true`, metadata files, such as index mappings and settings, are compressed
  135. in snapshots. Data files are not compressed. Defaults to `true`.
  136. `max_number_of_snapshots`::
  137. (Optional, integer)
  138. Maximum number of snapshots the repository can contain.
  139. Defaults to `Integer.MAX_VALUE`, which is `2^31-1` or `2147483647`.
  140. `max_restore_bytes_per_sec`::
  141. (Optional, <<byte-units,byte value>>)
  142. Maximum snapshot restore rate per node. Defaults to unlimited. Note
  143. that restores are also throttled through <<recovery,recovery settings>>.
  144. `max_snapshot_bytes_per_sec`::
  145. (Optional, <<byte-units,byte value>>)
  146. Maximum snapshot creation rate per node. Defaults to `40mb` per second.
  147. `readonly`::
  148. (Optional, Boolean)
  149. If `true`, the repository is read-only. The cluster can retrieve and restore
  150. snapshots from the repository but not write to the repository or create
  151. snapshots in it.
  152. +
  153. If `false`, the cluster can write to the repository and create snapshots in it.
  154. Defaults to `false`.
  155. +
  156. [TIP]
  157. =====
  158. If you register the same snapshot repository with multiple clusters, only
  159. one cluster should have write access to the repository. Having multiple clusters
  160. write to the repository at the same time risks corrupting the contents of the
  161. repository.
  162. Only a cluster with write access can create snapshots in the repository. All
  163. other clusters connected to the repository should have the `readonly` parameter
  164. set to `true`. This means those clusters can retrieve or restore snapshots from
  165. the repository but not create snapshots in it.
  166. =====
  167. ====
  168. Other accepted `settings` properties depend on the repository type, set using the
  169. <<put-snapshot-repo-api-request-type,`type`>> parameter.
  170. .Valid `settings` properties for `fs` repositories
  171. [%collapsible%open]
  172. ====
  173. `location`::
  174. (Required, string)
  175. Location of the shared filesystem used to store and retrieve snapshots. This
  176. location must be registered in the `path.repo` setting on all master and data
  177. nodes in the cluster.
  178. ====
  179. .Valid `settings` properties for `source` repositories
  180. [%collapsible%open]
  181. ====
  182. `delegate_type`::
  183. (Optional, string)
  184. Delegated repository type. For valid values, see the
  185. <<put-snapshot-repo-api-request-type,`type` parameter>>.
  186. +
  187. `source` repositories can use `settings` properties for its delegated repository
  188. type. See <<snapshots-source-only-repository>>.
  189. ====
  190. .Valid `settings` properties for `url` repositories
  191. [%collapsible%open]
  192. ====
  193. `url`::
  194. (Required, string)
  195. URL location of the root of the shared filesystem repository. The following
  196. protocols are supported:
  197. * `file`
  198. * `ftp`
  199. * `http`
  200. * `https`
  201. * `jar`
  202. URLs using the `file` protocol must point to the location of a shared filesystem
  203. accessible to all master and data nodes in the cluster. This location must be
  204. registered in the `path.repo` setting.
  205. URLs using the `http`, `https`, or `ftp` protocols must be explicitly allowed with the
  206. `repositories.url.allowed_urls` setting. This setting supports wildcards in the
  207. place of a host, path, query, or fragment in the URL.
  208. ====
  209. --
  210. `verify`::
  211. (Optional, Boolean)
  212. If `true`, the request verifies the repository is functional on all master and
  213. data nodes in the cluster. If `false`, this verification is skipped. Defaults to
  214. `true`.
  215. +
  216. You can manually perform this verification using the
  217. <<snapshots-repository-verification,verify snapshot repository API>>.