[[snapshots-source-only-repository]]
=== Source-only repository

You can use a source-only repository to take minimal, source-only snapshots that
use up to 50% less disk space than regular snapshots.

Unlike other repository types, a source-only repository doesn't directly store
snapshots. It delegates storage to another registered snapshot repository.

When you take a snapshot using a source-only repository, {es} creates a
source-only snapshot in the delegated storage repository. This snapshot only
contains stored fields and metadata. It doesn't include index or doc values
structures and isn't immediately searchable when restored. To search the
restored data, you first have to <<docs-reindex,reindex>> it into a new data
stream or index.

[IMPORTANT]
==================================================

Source-only snapshots are only supported if the `_source` field is enabled and no source-filtering is applied.
As a result, indices adopting synthetic source cannot be restored. When you restore a source-only snapshot:

 * The restored index is read-only and can only serve `match_all` search or scroll requests to enable reindexing.

 * Queries other than `match_all` and `_get` requests are not supported.

 * The mapping of the restored index is empty, but the original mapping is available from the types top
   level `meta` element.

 * Information such as document count, deleted document count and store size are not available for such indices
   since these indices do not contain the relevant data structures to retrieve this information from. Therefore,
   this information is not shown for such indices in APIs such as the <<cat-indices,cat indices API>>.
==================================================

Before registering a source-only repository, use {kib} or the
<<put-snapshot-repo-api,create snapshot repository API>> to register a snapshot
repository of another type to use for storage. Then register the source-only
repository and specify the delegated storage repository in the request.

[source,console]
----
PUT _snapshot/my_src_only_repository
{
  "type": "source",
  "settings": {
    "delegate_type": "fs",
    "location": "my_backup_repository"
  }
}
----
// TEST[setup:setup-repository]
// TEST[s/my_backup_repository/my_repository/]

[[source-only-repository-settings]]
==== Repository settings

`chunk_size`::
(Optional, <<byte-units,byte value>>)
Maximum size of files in snapshots. In snapshots, files larger than this are
broken down into chunks of this size or smaller. Defaults to `null` (unlimited
file size).

`compress`::
(Optional, Boolean)
If `true`, metadata files, such as index mappings and settings, are compressed
in snapshots. Data files are not compressed. Defaults to `true`.

`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 repository
type. See <<snapshots-source-only-repository>>.

`max_number_of_snapshots`::
(Optional, integer)
Maximum number of snapshots the repository can contain.
Defaults to `Integer.MAX_VALUE`, which is `2^31-1` or `2147483647`.

include::repository-shared-settings.asciidoc[]
