DEV Community

Shivesh Yadav
Shivesh Yadav

Posted on

Snapshot/Restore Elasticsearch using Curator

Well, first things first you will need Elasticsearch curator installed on your system.
I prefer installing it using pip as its easy peezy lemon squeezy. Just do
pip install elasticsearch-curator
There are other insane ways of installing it like using apt you can go to apt curator install instructions and follow the instructions there.
Now, the easy part. Follow along with the steps:

  • Create a snapshot directory.

mkdir -p /elasticsearchData/es-backup

  • Now, we need to give elasticsearch permissions to write to this directory. Provided the user running elasticsearch service is elasticsearch.

chown -R elasticsearch:elasticsearch /elasticsearchData/es-backup

  • Now we will give this backup path to elasticsearch by making an entry to the elasticsearch.yml

nano /etc/elasticsearch/elasticsearch.yml
and add
path.repo: ["/elasticseacrhData/es-backup"]

  • Next, we need to restart elasticsearch server. If you are on Ubuntu/Debian fire the below command.

sudo systemctl restart elasticsearch

  • Now we will add the created repository on to elasticsearch.

curl -XPUT -H "Content-Type: application/json;charset=UTF-8" 'http://localhost:9200/_snapshot/esbackup' -d '{
"type": "fs",
"settings": {
"location": "/elasticsearchData/es-backup",
"compress": true
}
}'

where esbackup is the name of the repository where ES data will be backed up.
You should get this

{"acknowledge": true}

response.

  • Now, we can take backup by firing a curl command. But here we will use Elasticsearch Curator for backup and restore.

  • You can get the yml files for curator here.

Required yml file for curatorTo take backup go to the scripts folder and run

/path/where/curator/is/installed/envs/envname_py3/bin/curator ./action_snapshot.yml - config ./curator_conf.yml

To restore from the backup go to the scripts folder and run.

/path/where/curator/is/installed/envs/envname_py3/bin/curator ./action_restore.yml - config ./curator_conf.yml

Voila, you will see your backup RESTORED.

Top comments (2)

Collapse
 
imadbouchakour profile image
Imad Bouchakour

hi,
i'm folowing the step but when restarting elasticsearch i got that erreur
java.lang.IllegalStateException: Unable to access 'path.repo' (/elasticseacrhData/es-backup)

drwxrwxrwx 3 elasticsearch elasticsearch elasticsearchData

Collapse
 
aravind profile image
Aravind Putrevu

Note: Curator is deprecated, please use Index Lifecycle Management from Elasticsearch further. There is also a Kibana UI that you could use and create these jobs.