I have to transfer an Elasticsearch index on a Windows machine to an Ubuntu Machine. I decided to take a snapshot of the index and then try to restore it on the other system.
I was successfully able to snapshot the index on the windows machine.
On the windows machine in elasticsearch.yml
I had path.repo: ["F:\\mount\\backups"]
.
So, under mount
I had:
.
└── backups
└── old_backup
├── index
├── indices
│ └── old_index
│ ├── 0
│ ├── 1
│ ├── 2
│ ├── 3
│ ├── 4
│ └── meta-snapshot_to_ubuntu.dat
├── meta-snapshot_to_ubuntu.dat
└── snap-snapshot_to_ubuntu.dat
where snapshot_to_ubuntu
is the name of the snapshot I made on Windows.
I placed this snapshot in ~/Documents/mount
on the ubuntu machine and start an instance of ES 2.3.0 with path.repo: ["/home/animesh/Documents/mount/backups"]
in elasticsearch.yml
.
I run the following on the command line:
curl -XGET localhost:9200/_snapshot/old_backup/snapshot_to_ubuntu?pretty=1
and get
{
"error" : {
"root_cause" : [ {
"type" : "repository_missing_exception",
"reason" : "[old_backup] missing"
} ],
"type" : "repository_missing_exception",
"reason" : "[old_backup] missing"
},
"status" : 404
}
Where am I going wrong?
UPDATE:
I ran the following curl command:
curl -X POST http://localhost:9200/_snapshot/old_backup/snapshot_to_ubuntu/_restore
and I get:
{
"error": {
"root_cause": [
{
"type": "repository_missing_exception",
"reason": "[old_backup] missing"
}
],
"type": "repository_missing_exception",
"reason": "[old_backup] missing"
},
"status": 404
}
I had a similar issue and I would like to share with you how I figured it out. I will write all steps, hope it may helps other people as well.
I had to transfer an Elasticsearch index on a GCP server to my Local Machine. I decided to take a snapshot of the index and then try to restore it on my Local machine.
I'm assuming you already have the snapshot/s
The steps are:
Create a directory on your local machine with the snapshot/s you want to restore
Navigate to elasticsearch.yml
file. For example, on my local machine, you can find the file here: /usr/local/Cellar/elasticsearch/7.8.1/libexec/config/elasticsearch.yml
add the repository path: path.repo: [PATH_TO_BACKUP_DIR]
on the elasticsearch.yml
file. For example: path.repo: ["/mount/backups", "/mount/longterm_backups"]
save, exit, and restart elasticsearch
After all nodes are restarted, the following command can be used to register the shared file system repository with the name my_fs_backup
curl -X PUT "localhost:9200/_snapshot/my_fs_backup?pretty" -H 'Content-Type: application/json' -d' { "type": "fs", "settings": { "location": "PATH_TO_BACKUP_DIR", // Example: location" : "/usr/local/etc/elasticsearch/elastic-backup" "compress": true } }'
Check your configuration: curl -X GET "localhost:9200/_snapshot/_all?pretty"
Restore from snapshot:
8.1 Get all snapshots: curl -X GET "localhost:9200/_snapshot/my_fs_backup/*?pretty
You will get this screen:
Pick the snapshot you want (In case you have more than one)
Use this command to restore:
curl -X POST "localhost:9200/_snapshot/BACKUP_NAME/SNAPSHOT_ID/_restore?pretty" -H 'Content-Type: application/json' -d'
{
"indices": "users, events",
"ignore_unavailable": true,
"include_global_state": true
}
For example:
curl -X POST "localhost:9200/_snapshot/my_fs_backup/elastic-snapshot-2020.09.05-lwul1zb9qaorq0k9vmd5rq/_restore?pretty" -H 'Content-Type: application/json' -d'
{
"indices": "users, events",
"ignore_unavailable": true,
"include_global_state": true
}
Pay attention that I imported only 2 indices users
and events
Hope it helps 😃
More info and extended tutorials: Elastic website, jee-appy blogspot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With