| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 | [[put-snapshot-repo-api]]=== Create or update snapshot repository API++++<titleabbrev>Create or update snapshot repository</titleabbrev>++++Registers or updates a <<snapshots-register-repository,snapshot repository>>.[source,console]----PUT /_snapshot/my_repository{  "type": "fs",  "settings": {    "location": "my_backup_location"  }}----[[put-snapshot-repo-api-request]]==== {api-request-title}`PUT /_snapshot/<repository>``POST /_snapshot/<repository>`[[put-snapshot-repo-api-prereqs]]==== {api-prereq-title}* If the {es} {security-features} are enabled, you must have the `manage`<<privileges-list-cluster,cluster privilege>> to use this API.[[put-snapshot-repo-api-desc]]==== {api-description-title}A snapshot repository must be registered before you can perform<<snapshot-restore,snapshot and restore>> operations. You can use the putsnapshot repository API to register new repositories and update existing ones.See <<snapshots-register-repository>>.TIP: Because snapshot formats can change between major versions of{es}, we recommend registering a new snapshot repository for each major version.See <<snapshot-restore-version-compatibility>>.[[put-snapshot-repo-api-path-params]]==== {api-path-parms-title}`<repository>`::(Required, string)Name of the snapshot repository to register or update.[[put-snapshot-repo-api-query-params]]==== {api-query-parms-title}IMPORTANT: Several options for this API can be specified using a query parameteror a request body parameter. If both parameters are specified, only the queryparameter is used.`master_timeout`::(Optional, <<time-units, time units>>) Specifies the period of time to wait fora connection to the master node. If no response is received before the timeoutexpires, the request fails and returns an error. Defaults to `30s`.`timeout`::(Optional, <<time-units, time units>>) Specifies the period of time to wait fora response. If no response is received before the timeout expires, the requestfails and returns an error. Defaults to `30s`.`verify`::(Optional, Boolean)If `true`, the request verifies the repository is functional on all master anddata nodes in the cluster. If `false`, this verification is skipped. Defaults to`true`.+You can manually perform this verification using the<<verify-snapshot-repo-api,verify snapshot repository API>>.[role="child_attributes"][[put-snapshot-repo-api-request-body]]==== {api-request-body-title}`master_timeout`::(Optional, <<time-units, time units>>)Specifies the period of time to wait fora connection to the master node. If no response is received before the timeoutexpires, the request fails and returns an error. Defaults to `30s`.`timeout`::(Optional, <<time-units, time units>>)Specifies the period of time to wait fora response. If no response is received before the timeout expires, the requestfails and returns an error. Defaults to `30s`.[[put-snapshot-repo-api-request-type]]`type`::+--(Required, string)Repository type..Valid values for `type`[%collapsible%open]====`fs`::Shared file system repository. Repositories of this type use a shared filesystem to store snapshots. This file system must accessible to all master anddata nodes in the cluster.+IMPORTANT: To register a shared file system repository, you must mount the sameshared filesystem to the same location on all master and data nodes. Thislocation must be registered in the `path.repo` setting on all master and datanodes in the cluster.+See <<snapshots-filesystem-repository>>.[xpack]#`source`#::Source-only repository. You can use source-only repositories to create minimal,source-only snapshots that take up to 50% less space on disk.+Source-only snapshots are only supported if the <<mapping-source-field,`_source`field>> is enabled and no<<source-filtering,source-filtering>> is applied.+WARNING: Source-only snapshots contain stored fields and index metadata. They donot include index or doc values structures and are not searchable when restored.After restoring a source-only snapshot, you must <<docs-reindex,reindex>> thedata into a new index.+See <<snapshots-source-only-repository>>.`url`::URL repository. Repositories of this type are read-onlyfor the cluster. This means the cluster can retrieve or restore snapshots fromthe repository but cannot write or create snapshots in it.+You can use URL repositories as an alternative way to give a cluster read-onlyaccess to a shared file system (`fs`) repository.+See <<snapshots-read-only-repository>>.====More repository types are available through these officialplugins:* {plugins}/repository-s3.html[repository-s3] for S3 repository support* {plugins}/repository-hdfs.html[repository-hdfs] for HDFS repository support in  Hadoop environments* {plugins}/repository-azure.html[repository-azure] for Azure storage  repositories* {plugins}/repository-gcs.html[repository-gcs] for Google Cloud Storage  repositories--[[put-snapshot-repo-api-settings-param]]`settings`::+--(Required, object)Contains settings for the repository.The following `settings` properties are valid for all repository types:.Properties of `settings`[%collapsible%open]====`chunk_size`::(Optional, <<byte-units,byte value>>)Maximum size of files in snapshots. In snapshots, files larger than this arebroken down into chunks of this size or smaller. Defaults to `null` (unlimitedfile size).`compress`::(Optional, Boolean)If `true`, metadata files, such as index mappings and settings, are compressedin snapshots. Data files are not compressed. Defaults to `true`.`max_number_of_snapshots`::(Optional, integer)Maximum number of snapshots the repository can contain. Defaults to `500`.+WARNING: We do not recommend increasing `max_number_of_snapshots`. Largersnapshot repositories may degrade master node performance and cause stabilityissues. Instead, delete older snapshots or use multiple repositories.`max_restore_bytes_per_sec`::(Optional, <<byte-units,byte value>>)Maximum snapshot restore rate per node. Defaults to unlimited. Notethat restores are also throttled through <<recovery,recovery settings>>.`max_snapshot_bytes_per_sec`::(Optional, <<byte-units,byte value>>)Maximum snapshot creation rate per node. Defaults to `40mb` per second.`readonly`::(Optional, Boolean)If `true`, the repository is read-only. The cluster can retrieve and restoresnapshots from the repository but not write to the repository or createsnapshots in it.+If `false`, the cluster can write to the repository and create snapshots in it.Defaults to `false`.+[TIP]=====If you register the same snapshot repository with multiple clusters, onlyone cluster should have write access to the repository. Having multiple clusterswrite to the repository at the same time risks corrupting the contents of therepository.Only a cluster with write access can create snapshots in the repository. Allother clusters connected to the repository should have the `readonly` parameterset to `true`. This means those clusters can retrieve or restore snapshots fromthe repository but not create snapshots in it.=========Other accepted `settings` properties depend on the repository type, set using the<<put-snapshot-repo-api-request-type,`type`>> parameter..Valid `settings` properties for `fs` repositories[%collapsible%open]====`location`::(Required, string)Location of the shared filesystem used to store and retrieve snapshots. Thislocation must be registered in the `path.repo` setting on all master and datanodes in the cluster.====.Valid `settings` properties for `source` repositories[%collapsible%open]====`delegate_type`::(Optional, string)Delegated repository type. For valid values, see the<<put-snapshot-repo-api-request-type,`type` parameter>>.+`source` repositories can use `settings` properties for its delegated repositorytype. See <<snapshots-source-only-repository>>.====.Valid `settings` properties for `url` repositories[%collapsible%open]====`url`::(Required, string)URL location of the root of the shared filesystem repository. The followingprotocols are supported:* `file`* `ftp`* `http`* `https`* `jar`URLs using the `file` protocol must point to the location of a shared filesystemaccessible to all master and data nodes in the cluster. This location must beregistered in the `path.repo` setting.URLs using the `http`, `https`, or `ftp` protocols must be explicitly allowed with the`repositories.url.allowed_urls` setting. This setting supports wildcards in theplace of a host, path, query, or fragment in the URL.====--`verify`::(Optional, Boolean)If `true`, the request verifies the repository is functional on all master anddata nodes in the cluster. If `false`, this verification is skipped. Defaults to`true`.+You can manually perform this verification using the<<snapshots-repository-verification,verify snapshot repository API>>.
 |