Book Image

ElasticSearch Cookbook

By : Alberto Paro
Book Image

ElasticSearch Cookbook

By: Alberto Paro

Overview of this book

Table of Contents (20 chapters)
ElasticSearch Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Restoring a snapshot


After you have taken snapshots of your data, they can be restored. The restoration process is often very fast; the indexed data is copied on the nodes and then activated.

Getting ready

You need a working ElasticSearch cluster and the snapshot created in the previous recipe.

How to do it...

To restore a snapshot, we will perform the following step:

  • To restore a snapshot called snap_1 for the index test and test2, the HTTP method is PUT, and the curl command is:

    curl -XPOST "localhost:9200/_snapshot/my_backup/snap_1/_restore?pretty" -d '{
      "indices": "test-index,test-2",
      "ignore_unavailable": "true",
      "include_global_state": false,
      "rename_pattern": "test-(.+)",
      "rename_replacement": "copy_$1"
    }'
    

    The result will be as follows:

    {
      "accepted" : true
    }

The restoration is finished when the cluster state turns from red to yellow or green.

How it works...

The restoration process is very fast. It is internally composed of the following steps:

  • The data is copied on the primary...