put-repo-api.asciidoc 8.8 KB

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