restore_snapshot.asciidoc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. [[java-rest-high-snapshot-restore-snapshot]]
  2. === Restore Snapshot API
  3. The Restore Snapshot API allows to restore a snapshot.
  4. [[java-rest-high-snapshot-restore-snapshot-request]]
  5. ==== Restore Snapshot Request
  6. A `RestoreSnapshotRequest`:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request]
  10. --------------------------------------------------
  11. ==== Limiting Indices to Restore
  12. By default all indices are restored. With the `indices` property you can
  13. provide a list of indices that should be restored:
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request-indices]
  17. --------------------------------------------------
  18. <1> Request that Elasticsearch only restores "test_index".
  19. ==== Renaming Indices
  20. You can rename indices using regular expressions when restoring a snapshot:
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request-rename]
  24. --------------------------------------------------
  25. <1> A regular expression matching the indices that should be renamed.
  26. <2> A replacement pattern that references the group from the regular
  27. expression as `$1`. "test_index" from the snapshot is restored as
  28. "restored_index" in this example.
  29. ==== Index Settings and Options
  30. You can also customize index settings and options when restoring:
  31. ["source","java",subs="attributes,callouts,macros"]
  32. --------------------------------------------------
  33. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request-index-settings]
  34. --------------------------------------------------
  35. <1> Use `#indexSettings()` to set any specific index setting for the indices
  36. that are restored.
  37. <2> Use `#ignoreIndexSettings()` to provide index settings that should be
  38. ignored from the original indices.
  39. <3> Set `IndicesOptions.Option.IGNORE_UNAVAILABLE` in `#indicesOptions()` to
  40. have the restore succeed even if indices are missing in the snapshot.
  41. ==== Further Arguments
  42. The following arguments can optionally be provided:
  43. ["source","java",subs="attributes,callouts,macros"]
  44. --------------------------------------------------
  45. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request-masterTimeout]
  46. --------------------------------------------------
  47. <1> Timeout to connect to the master node as a `TimeValue`
  48. <2> Timeout to connect to the master node as a `String`
  49. ["source","java",subs="attributes,callouts,macros"]
  50. --------------------------------------------------
  51. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request-waitForCompletion]
  52. --------------------------------------------------
  53. <1> Boolean indicating whether to wait until the snapshot has been restored.
  54. ["source","java",subs="attributes,callouts,macros"]
  55. --------------------------------------------------
  56. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request-partial]
  57. --------------------------------------------------
  58. <1> Boolean indicating whether the entire snapshot should succeed although one
  59. or more indices participating in the snapshot don’t have all primary
  60. shards available.
  61. ["source","java",subs="attributes,callouts,macros"]
  62. --------------------------------------------------
  63. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request-include-global-state]
  64. --------------------------------------------------
  65. <1> Boolean indicating whether restored templates that don’t currently exist
  66. in the cluster are added and existing templates with the same name are
  67. replaced by the restored templates. The restored persistent settings are
  68. added to the existing persistent settings.
  69. ["source","java",subs="attributes,callouts,macros"]
  70. --------------------------------------------------
  71. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-request-include-aliases]
  72. --------------------------------------------------
  73. <1> Boolean to control whether aliases should be restored. Set to `false` to
  74. prevent aliases from being restored together with associated indices.
  75. [[java-rest-high-snapshot-restore-snapshot-sync]]
  76. ==== Synchronous Execution
  77. ["source","java",subs="attributes,callouts,macros"]
  78. --------------------------------------------------
  79. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-execute]
  80. --------------------------------------------------
  81. [[java-rest-high-snapshot-restore-snapshot-async]]
  82. ==== Asynchronous Execution
  83. The asynchronous execution of a restore snapshot request requires both the
  84. `RestoreSnapshotRequest` instance and an `ActionListener` instance to be
  85. passed to the asynchronous method:
  86. ["source","java",subs="attributes,callouts,macros"]
  87. --------------------------------------------------
  88. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-execute-async]
  89. --------------------------------------------------
  90. <1> The `RestoreSnapshotRequest` to execute and the `ActionListener`
  91. to use when the execution completes
  92. The asynchronous method does not block and returns immediately. Once it is
  93. completed the `ActionListener` is called back using the `onResponse` method
  94. if the execution successfully completed or using the `onFailure` method if
  95. it failed.
  96. A typical listener for `RestoreSnapshotResponse` looks like:
  97. ["source","java",subs="attributes,callouts,macros"]
  98. --------------------------------------------------
  99. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-execute-listener]
  100. --------------------------------------------------
  101. <1> Called when the execution is successfully completed. The response is
  102. provided as an argument.
  103. <2> Called in case of a failure. The raised exception is provided as an argument.
  104. [[java-rest-high-cluster-restore-snapshot-response]]
  105. ==== Restore Snapshot Response
  106. The returned `RestoreSnapshotResponse` allows to retrieve information about the
  107. executed operation as follows:
  108. ["source","java",subs="attributes,callouts,macros"]
  109. --------------------------------------------------
  110. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[restore-snapshot-response]
  111. --------------------------------------------------
  112. <1> The `RestoreInfo` contains details about the restored snapshot like the indices or
  113. the number of successfully restored and failed shards.