Briefly, this error occurs when you try to restore a snapshot that was created with a different, usually older, version of Elasticsearch. The snapshot and the Elasticsearch version you’re trying to restore it to are incompatible. To resolve this issue, you can either upgrade your Elasticsearch to the version compatible with the snapshot, or create a new snapshot with the current version of Elasticsearch. Alternatively, you can restore the snapshot to a compatible Elasticsearch version, reindex the data, and then take a new snapshot to restore on the current version.
This guide will help you check for common problems that cause the log ” cannot restore incompatible snapshot ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: snapshot, restore.
Overview
In Elasticsearch, restore refers to the snapshot restore mechanism, which returns indices or clusters to a previous, saved state. You can restore the entire cluster from the snapshot or restore an individual index or selected indices.
Examples
To restore the whole snapshot:
POST /_snapshot/my_backup/snapshot-01-11-2019/_restore
To restore an individual index:
POST /_snapshot/my_backup/snapshot-01-11-2019/_restore { "indices": "my_index" }
Notes
- If you are using a security tool like Searchguard, the snapshot restore capability must be enabled in elasticsearch.yml. Otherwise, it will throw a security exception.
Common issues
- If an index or indices already exist with the same names as those you are going to restore, they need to either be closed or deleted before you can restore from a snapshot. Otherwise, the restore operation will fail due to an error that the index already exists.
Log Context
Log “cannot restore incompatible snapshot” class name is RestoreService.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :
final RepositoryData repositoryData = repository.getRepositoryData(); final String snapshotName = request.snapshot(); final OptionalincompatibleSnapshotId = repositoryData.getIncompatibleSnapshotIds().stream().filter(s -> snapshotName.equals(s.getName())).findFirst(); if (incompatibleSnapshotId.isPresent()) { throw new SnapshotRestoreException(repositoryName; snapshotName; "cannot restore incompatible snapshot"); } final Optional matchingSnapshotId = repositoryData.getSnapshotIds().stream() .filter(s -> snapshotName.equals(s.getName())).findFirst(); if (matchingSnapshotId.isPresent() == false) { throw new SnapshotRestoreException(repositoryName; snapshotName; "snapshot does not exist");