Maintenance
Backup Elasticsearch Data
- Snapshot Repository Configuration:
Open /etc/elasticsearch/elasticsearch.yml and configure a snapshot repository
path.repo: ["/path/to/backup"]
Replace /path/to/backup with the actual path where you want to store snapshots
- Restart Elasticsearch
After making changes, restart the Elasticsearch service
sudo systemctl restart elasticsearch
- Create Snapshot
Use the following command to create a snapshot
curl -X PUT "localhost:9200/_snapshot/my_backup" -H 'Content-Type: application/json' -d '{
"type": "fs",
"settings": {
"location": "/path/to/backup"
}
}'
Replace /path/to/backup with the actual path
Restore Elasticsearch Data Stop Elasticsearch
sudo systemctl stop elasticsearch
sudo systemctl stop elasticsearch
- Restore Snapshot
Use the following command to restore the snapshot
curl -X POST "localhost:9200/_snapshot/my_backup/snapshot_name/_restore"
Replace snapshot_name with the actual name of your snapshot
- Start Elasticsearch
sudo systemctl start elasticsearch