How to perform a backup and restore of Elasticsearch?
Perform the below steps for Elasticsearch backup and restore and migration also
- Create a shared drive accessible for both the location (calling A and B for simplicity)
- Open yml file of ES in server A
- Add the line: path.repo: [] and save. Note that the shared file should have escape "\" as well
Eg. path.repo: ["\\\\servername.com\\ESbackupfolder
backup"] - Restart the service
- Open Kibana website - Dev tools
- Run the below script
- Create Repository
{
"type": "fs",
"settings": {
"location": "\\servername.com\\ESbackupfolder
backup"
}
}
Success:
Error:
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..)
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
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
- Add snapshot
- Copy the snapshot
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
Deleting Indices:
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 .