Share a repository across clustersedit
Create a custom repository that references another cluster’s repository.
To restore a snapshot from one cluster to another cluster, both clusters must be in the same region.
If you do a GET /_snapshot/found-snapshots
request, you can find the name of your bucket. Here’s an example:
On S3 { "found-snapshots" : { "type" : "s3", "settings" : { "bucket" : "[RANDOM_STRING]", "base_path" : "snapshots/[cluster-id]", "server_side_encryption" : "true", "compress" : "true" } } } On Azure { "found-snapshots": { "type": "azure", "uuid": "rZOzI7s7RPiGZlv9OdcRhQ", "settings": { "container": "c8dc7246645e54394993b2d20b25d50", "client": "elastic-internal-9a8415", "base_path": "snapshots/9a8415caf32b4c1aa243b61c355ca2e2", "container_name": "c8dc7246645e54394993b2d20b25d50", "use_for_peer_recovery": "true" } } }
The random string bucket name is the same for all your clusters in that region. All nodes in your clusters in that region are configured with credentials that have access to that bucket. The only thing that differs is the base_path
.
You can create a reference to the repository associated with another cluster by creating a second repository. For example, to copy indices from a production cluster to a dev cluster, you can run PUT /_snapshot/production
on the dev cluster with the following body to create a second repository. Ensure to use readonly
when you register the same repository with multiple clusters as only one cluster (in this case, production) should have write access to the repository while all other connected clusters (in this case, dev) have readonly
access. For example:
{ "type": "s3", "settings" : { "bucket": "[RANDOM_STRING]", "base_path": "snapshots/[production-cluster-id]", "server_side_encryption": "true", "compress": "true", "readonly": "true", "aws_account": "[my-operations-account]", "client": "[dev-client]" } }
You should get snapshots on the dev cluster from the production cluster with GET _snapshot/production/_all
. Then you can restore indices from the production cluster to the dev cluster by, for example, running POST /_snapshot/production/[my-snapshot]/_restore
on the dev cluster.
When you use the same repository across clusters, you are responsible for not writing to the same location at the same time.