Can't restore snapshot in Elasticsearch-2.3.3

I want to upgrade to 2.3.3 from 1.5.1.
So I got 1.5.1 snapshot and I want to restore the 1.5.1 snapshot in 2.3.3.
By the way, 2.3.3 is newly built.

However, the following error occurred.
Because maybe snap-posts_v3_20160628.dat not found.

{
  "error" : {
    "root_cause" : [ {
      "type" : "snapshot_missing_exception",
      "reason" : "[snapshot1:posts_v3_20160628] is missing"
    } ],
    "type" : "snapshot_missing_exception",
    "reason" : "[snapshot1:posts_v3_20160628] is missing",
    "caused_by" : {
      "type" : "no_such_file_exception",
      "reason" : "/var/elasticsearch/snapshot/snapshot1/snap-posts_v3_20160628.dat"
    }
  },
  "status" : 404
}

Getting snapshot in 1.5.1, *.dat file is not created.

drwxr-xr-x 3 elasticsearch elasticsearch 4096  6月 29 02:30 .
drwxr-xr-x 4 elasticsearch elasticsearch 4096  6月 29 01:46 ..
-rw-r--r-- 1 elasticsearch elasticsearch   58  6月 28 08:31 index
drwxr-xr-x 4 elasticsearch elasticsearch 4096  6月 28 08:31 indices
-rw-r--r-- 1 elasticsearch elasticsearch   61  6月 28 08:30 metadata-posts_v3_20160628
-rw-r--r-- 1 elasticsearch elasticsearch  188  6月 28 08:30 snapshot-posts_v3_20160628

How do I restore the 1.5.1 of the data ?

Here is my opinion.

First upgrade all machines to the latest 1.7 version. You can do a rolling upgrade.
Then install the migration plugin. It will tell you if you can directly upgrade to 2.x or not.

Depending on the result, you might have to run the upgrade API then snapshot.

Then you could restore in the 2.3 instances.

My 2 cents

2 Likes

Thanks. But it failed.
By 1.7 getting snapshot, *.dat file is not created and failed to restore to 2.3.

Can you describe all the exact steps you did so far?

Yes.
Raise the version from 1.5 to 1.7 in the First.

$ sudo rpm -ivh --replacefiles https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.0.noarch.rpm
$ sudo mv /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml_1.5.1
$ sudo mv /etc/elasticsearch/elasticsearch.yml.rpmsave /etc/elasticsearch/elasticsearch.yml
$ sudo survice elasticsearch start
$ curl localhost:9200
{
  "status" : 200,
  "name" : "Caleb Alexander",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.7.0",
    "build_hash" : "929b9739cae115e73c346cb5f9a6f24ba735a743",
    "build_timestamp" : "2015-07-16T14:31:07Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

Next take a snapshot

$ sudo mkdir -p /var/elasticsearch/snapshot
$ sudo chown -R elasticsearch:elasticsearch /var/elasticsearch

...

Append the following to elasticsearch.yml
path.repo: ["/var/elasticsearch/snapshot"]

...

$ sudo service elasticsearch restart
$ curl -XPUT 'http://localhost:9200/_snapshot/snapshot1' -d '
{
  "type": "fs",
  "settings": {
    "location": "/var/elasticsearch/snapshot/snapshot1",
    "compress": true
  }
}
'
$ curl -XPUT localhost:9200/_snapshot/snapshot1/posts_v2_20160622?wait_for_completion=true -d '
{
  "indices": "posts_v2",
  "ignore_unavailable": "true",
  "include_global_state": false
}
'
$ exit

Copy snapshot directory to /tmp in 2.3.3 server, And then restore to 2.3.3

$ sudo mkdir -p /var/elasticsearch/snapshot
$ mv /tmp/snapshot1 /var/elasticsearch/snapshot/snapshot1
$ sudo chown -R elasticsearch:elasticsearch /var/elasticsearch

...

Append the following to elasticsearch.yml
path.repo: ["/var/elasticsearch/snapshot"]

...

$ sudo service elasticsearch restart
$ curl -XPUT 'http://localhost:9200/_snapshot/snapshot1' -d '
{
  "type": "fs",
  "settings": {
    "location": "/var/elasticsearch/snapshot/snapshot1",
    "compress": true
  }
}
'
$ curl -XPOST localhost:9200/_snapshot/snapshot1/posts_v2_20160622/_restore?pretty -d '
{
  "indices": "posts_v2",
  "ignore_unavailable": "true",
  "include_global_state": false,
  "rename_pattern": "posts_v2",
  "rename_replacement": "posts_v3"
}
'
{
  "error" : {
    "root_cause" : [ {
      "type" : "snapshot_missing_exception",
      "reason" : "[snapshot1:posts_v2_20160622] is missing"
    } ],
    "type" : "snapshot_missing_exception",
    "reason" : "[snapshot1:posts_v2_20160622] is missing",
    }
  },
"status" : 404
}

Upgrading to 1.7, no_such_file_exception didn't show but it failed restore.

Thanks for the detailed report. I'm pinging @Igor_Motov about it in case I missed something obvious.

I wonder why you installed 1.7.0 instead of 1.7.5?

1 Like

@dadoonet
Thank you for the important tips !
Then I tried to restore from 1.7.5 to 2.2.3 .
And it was successful .

Great! Thanks for confirming.

1 Like