Skip to main content
Version: 6.11.0

Create snapshot of Elasticsearch data

On the source server, create a new directory to store the snapshots, in this case /opt/waratek/elasticsearch-backup:

mdkir /opt/waratek/elasticsearch-backup

Update permissions to ensure the elasticsearchuser owns the snapshot directory:

sudo chown -R elasticsearch:elasticsearch /opt/waratek/elasticsearch-backup

Configure Elasticsearch with the path to the snapshot directory by adding an entry for the path to /etc/elasticsearch/elasticsearch.yml:

path.repo: /opt/waratek/elasticsearch-backup

Restart the Elasticsearch service:

sudo systemctl restart elasticsearch.service
info

The steps below use the Elasticsearch API. User credentials may be required depending on the configured security.The credentials configured within the Portal Dedicated application.properties have sufficient permissions to run all the required tasks below.The examples use portal/Portal1234 as username/password and should be updated or removed as needed.The examples use https to connect to Elasticsearch, update to http as appropriate.

Using the Elasticsearch API register a snapshot repository specifying:

  • a repository name: snapshot-repository in the example below
  • the repository location: the full path to the directory created above
curl -XPUT -H "Content-Type: application/json" -k -u portal:Portal1234 "https://localhost:9200/_snapshot/snapshot-repository" -d '
{
"type": "fs",
"settings": {
"location": "/opt/waratek/elasticsearch-backup",
"compress": true
}
}'

Create a snapshot of all the indices specifying:

  • a repository name: same as created in the step above
  • a snapshot name: cluster-snapshot in the example below
curl -XPUT -k -u portal:Portal1234 "https://localhost:9200/_snapshot/snapshot-repository/cluster-snapshot?wait_for_completion=true"
Done

Once the command above is complete the cluster snapshot will be saved to the configured snapshot directory. This directory should be copied to the new server and used for the restore process.