WARNING: The 2.x versions of Elasticsearch have passed their EOL dates. If you are running a 2.x version, we strongly advise you to upgrade.
This documentation is no longer maintained and may be removed. For the latest information, see the current Elasticsearch documentation.
Restoring from a Snapshotedit
Once you’ve backed up some data, restoring it is easy: simply add _restore
to the ID of the snapshot you wish to restore into your cluster:
POST _snapshot/my_backup/snapshot_1/_restore
The default behavior is to restore all indices that exist in that snapshot.
If snapshot_1
contains five indices, all five will be restored into
our cluster. As with the snapshot
API, it is possible to select which indices
we want to restore.
There are also additional options for renaming indices. This allows you to match index names with a pattern, and then provide a new name during the restore process. This is useful if you want to restore old data to verify its contents, or perform some other processing, without replacing existing data. Let’s restore a single index from the snapshot and provide a replacement name:
POST /_snapshot/my_backup/snapshot_1/_restore { "indices": "index_1", "rename_pattern": "index_(.+)", "rename_replacement": "restored_index_$1" }
Restore only the |
|
Find any indices being restored that match the provided pattern. |
|
Then rename them with the replacement pattern. |
This will restore index_1
into your cluster, but rename it to restored_index_1
.
Similar to snapshotting, the restore
command will return immediately, and the
restoration process will happen in the background. If you would prefer your HTTP
call to block until the restore is finished, simply add the wait_for_completion
flag:
POST _snapshot/my_backup/snapshot_1/_restore?wait_for_completion=true
Monitoring Restore Operationsedit
The restoration of data from a repository piggybacks on the existing recovery mechanisms already in place in Elasticsearch. Internally, recovering shards from a repository is identical to recovering from another node.
If you wish to monitor the progress of a restore, you can use the recovery
API. This is a general-purpose API that shows the status of shards moving around
your cluster.
The API can be invoked for the specific indices that you are recovering:
GET restored_index_3/_recovery
Or for all indices in your cluster, which may include other shards moving around, unrelated to your restore process:
GET /_recovery/
The output will look similar to this (and note, it can become very verbose depending on the activity of your cluster!):
{ "restored_index_3" : { "shards" : [ { "id" : 0, "type" : "snapshot", "stage" : "index", "primary" : true, "start_time" : "2014-02-24T12:15:59.716", "stop_time" : 0, "total_time_in_millis" : 175576, "source" : { "repository" : "my_backup", "snapshot" : "snapshot_3", "index" : "restored_index_3" }, "target" : { "id" : "ryqJ5lO5S4-lSFbGntkEkg", "hostname" : "my.fqdn", "ip" : "10.0.1.7", "name" : "my_es_node" }, "index" : { "files" : { "total" : 73, "reused" : 0, "recovered" : 69, "percent" : "94.5%" }, "bytes" : { "total" : 79063092, "reused" : 0, "recovered" : 68891939, "percent" : "87.1%" }, "total_time_in_millis" : 0 }, "translog" : { "recovered" : 0, "total_time_in_millis" : 0 }, "start" : { "check_index_time" : 0, "total_time_in_millis" : 0 } } ] } }
The |
|
The |
|
The |
The output will list all indices currently undergoing a recovery, and then list all shards in each of those indices. Each shard will have stats about start/stop time, duration, recover percentage, bytes transferred, and more.
Canceling a Restoreedit
To cancel a restore, you need to delete the indices being restored. Because
a restore process is really just shard recovery, issuing a delete-index
API
alters the cluster state, which will in turn halt recovery. For example:
DELETE /restored_index_3
If restored_index_3
was actively being restored, this delete command would
halt the restoration as well as deleting any data that had already been restored
into the cluster.
- Elasticsearch - The Definitive Guide:
- Foreword
- Preface
- Getting Started
- You Know, for Search…
- Installing and Running Elasticsearch
- Talking to Elasticsearch
- Document Oriented
- Finding Your Feet
- Indexing Employee Documents
- Retrieving a Document
- Search Lite
- Search with Query DSL
- More-Complicated Searches
- Full-Text Search
- Phrase Search
- Highlighting Our Searches
- Analytics
- Tutorial Conclusion
- Distributed Nature
- Next Steps
- Life Inside a Cluster
- Data In, Data Out
- What Is a Document?
- Document Metadata
- Indexing a Document
- Retrieving a Document
- Checking Whether a Document Exists
- Updating a Whole Document
- Creating a New Document
- Deleting a Document
- Dealing with Conflicts
- Optimistic Concurrency Control
- Partial Updates to Documents
- Retrieving Multiple Documents
- Cheaper in Bulk
- Distributed Document Store
- Searching—The Basic Tools
- Mapping and Analysis
- Full-Body Search
- Sorting and Relevance
- Distributed Search Execution
- Index Management
- Inside a Shard
- You Know, for Search…
- Search in Depth
- Structured Search
- Full-Text Search
- Multifield Search
- Proximity Matching
- Partial Matching
- Controlling Relevance
- Theory Behind Relevance Scoring
- Lucene’s Practical Scoring Function
- Query-Time Boosting
- Manipulating Relevance with Query Structure
- Not Quite Not
- Ignoring TF/IDF
- function_score Query
- Boosting by Popularity
- Boosting Filtered Subsets
- Random Scoring
- The Closer, The Better
- Understanding the price Clause
- Scoring with Scripts
- Pluggable Similarity Algorithms
- Changing Similarities
- Relevance Tuning Is the Last 10%
- Dealing with Human Language
- Aggregations
- Geolocation
- Modeling Your Data
- Administration, Monitoring, and Deployment