put-repo-api.asciidoc 8.6 KB

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