put-repo-api.asciidoc 8.3 KB

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