NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Restore Snapshot API
editRestore Snapshot API
editThe Restore Snapshot API allows to restore a snapshot.
Restore Snapshot Request
editA RestoreSnapshotRequest
:
RestoreSnapshotRequest request = new RestoreSnapshotRequest(repositoryName, snapshotName);
Limiting Indices to Restore
editBy default all indices are restored. With the indices
property you can
provide a list of indices that should be restored:
Renaming Indices
editYou can rename indices using regular expressions when restoring a snapshot:
Index Settings and Options
editYou 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 Arguments
editThe 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 Execution
editRestoreSnapshotResponse response = client.snapshot().restore(request, RequestOptions.DEFAULT);
Asynchronous Execution
editThe 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 Response
editThe returned RestoreSnapshotResponse
allows to retrieve information about the
executed operation as follows: