Elasticsearch Migration - Backup and Restore

How to perform a backup and restore of Elasticsearch?

Perform the below steps for Elasticsearch backup and restore and migration also

  1. Create a shared drive accessible for both the location (calling A and B for simplicity)
  2. Open yml file of ES in server A
  3. Add the line: path.repo: [] and save. Note that the shared file should have escape "\" as well
    Eg. path.repo: ["\\\\servername.com\\ESbackupfolder
    backup"]
  4. Restart the service
  5. Open Kibana website - Dev tools
  6. Run the below script
  • Create Repository
PUT /_snapshot/backup1
{
"type": "fs",
"settings": {
"location": "\\servername.com\\ESbackupfolder
backup"
}
}

Success:

image.png

Error:

image.png

Above error comes if the backup location is not mentioned in .yml file as path.repo . The same can be verified by using GET command

Command: GET _snapshot/backup1 (alternate repo's go by the name backup1, backup2 etc..)

image.png



Next Create the actual Backup: This will create a snapshot of all the data in the backup1 folder.

Command: PUT _snapshot/backup1/snapshot1?wait_for_completion=true

Note: Wait for completion = true will wait for the backup to complete before it acknowledges the result

image.png

Once the backup is complete, login to node 2 or new server and open the ES yml file

  • Perform same steps as above – add repo in yml or copy the yml file from primary node
  • Restart the service
  • Open Kibana -> Dev Tools and use below command to copy the snapshot into local server from the shared path
  1. Add snapshot

image.png

  1. Copy the snapshot

image.png




Note: Restoration of an index is not possible if the index is created in secondary server. Below error will be thrown. Delete all the index and then try importing the index. The available indexes can be checked with below URL: http://ElasticURL/_cat/indices

image.png


Deleting Indices:

image.png

Note: If Kibana does not load, it may be due to enhanced security option of IE blocking Kibana to load. Switch this off from Server Manager .