WARNING: Deprecated in 7.15.0.
The Java REST Client is deprecated in favor of the Java API Client.
Restore Snapshot APIedit
The Restore Snapshot API allows to restore a snapshot.
Restore Snapshot Requestedit
A RestoreSnapshotRequest
:
RestoreSnapshotRequest request = new RestoreSnapshotRequest(repositoryName, snapshotName);
Limiting Indices to Restoreedit
By default all indices are restored. With the indices
property you can
provide a list of indices that should be restored:
Renaming Indicesedit
You can rename indices using regular expressions when restoring a snapshot:
Index Settings and Optionsedit
You can also customize index settings and options when restoring:
request.indexSettings( Settings.builder() .put("index.number_of_replicas", 0) .build()); request.ignoreIndexSettings("index.refresh_interval", "index.search.idle.after"); request.indicesOptions(new IndicesOptions( EnumSet.of(IndicesOptions.Option.IGNORE_UNAVAILABLE), EnumSet.of(IndicesOptions.WildcardStates.OPEN)));
Use |
|
Use |
|
Set |
Further Argumentsedit
The following arguments can optionally be provided:
Timeout to connect to the master node as a |
|
Timeout to connect to the master node as a |
Boolean indicating whether the entire snapshot should succeed although one or more indices participating in the snapshot don’t have all primary shards available. |
Boolean indicating whether restored templates that don’t currently exist in the cluster are added and existing templates with the same name are replaced by the restored templates. The restored persistent settings are added to the existing persistent settings. |
Synchronous Executionedit
RestoreSnapshotResponse response = client.snapshot().restore(request, RequestOptions.DEFAULT);
Asynchronous Executionedit
The asynchronous execution of a restore snapshot request requires both the
RestoreSnapshotRequest
instance and an ActionListener
instance to be
passed to the asynchronous method:
The asynchronous method does not block and returns immediately. Once it is
completed the ActionListener
is called back using the onResponse
method
if the execution successfully completed or using the onFailure
method if
it failed.
A typical listener for RestoreSnapshotResponse
looks like:
Restore Snapshot Responseedit
The returned RestoreSnapshotResponse
allows to retrieve information about the
executed operation as follows: