monitor-snapshot-restore.asciidoc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. [[snapshots-monitor-snapshot-restore]]
  2. == Monitor snapshot and restore progress
  3. ++++
  4. <titleabbrev>Monitor snapshot and restore</titleabbrev>
  5. ++++
  6. Use the <<get-snapshot-api,get snapshot API>> or the
  7. <<get-snapshot-status-api,get snapshot status API>> to monitor the
  8. progress of snapshot operations. Both APIs support the
  9. `wait_for_completion` parameter that blocks the client until the
  10. operation finishes, which is the simplest method of being notified
  11. about operation completion.
  12. ////
  13. [source,console]
  14. -----------------------------------
  15. PUT /_snapshot/my_backup
  16. {
  17. "type": "fs",
  18. "settings": {
  19. "location": "my_backup_location"
  20. }
  21. }
  22. PUT /_snapshot/my_fs_backup
  23. {
  24. "type": "fs",
  25. "settings": {
  26. "location": "my_other_backup_location"
  27. }
  28. }
  29. PUT /_snapshot/my_backup/snapshot_1?wait_for_completion=true
  30. PUT /_snapshot/my_backup/some_other_snapshot?wait_for_completion=true
  31. -----------------------------------
  32. // TESTSETUP
  33. ////
  34. Use the `_current` parameter to retrieve all currently running
  35. snapshots in the cluster:
  36. [source,console]
  37. -----------------------------------
  38. GET /_snapshot/my_backup/_current
  39. -----------------------------------
  40. Including a snapshot name in the request retrieves information about a single snapshot:
  41. [source,console]
  42. -----------------------------------
  43. GET /_snapshot/my_backup/snapshot_1
  44. -----------------------------------
  45. This request retrieves basic information about the snapshot, including start and end time, version of
  46. {es} that created the snapshot, the list of included data streams and indices, the current state of the
  47. snapshot and the list of failures that occurred during the snapshot.
  48. Similar to repositories, you can retrieve information about multiple snapshots in a single request, and wildcards are supported:
  49. [source,console]
  50. -----------------------------------
  51. GET /_snapshot/my_backup/snapshot_*,some_other_snapshot
  52. -----------------------------------
  53. Separate repository names with commas or use wildcards to retrieve snapshots from multiple repositories:
  54. [source,console]
  55. -----------------------------------
  56. GET /_snapshot/_all
  57. GET /_snapshot/my_backup,my_fs_backup
  58. GET /_snapshot/my*/snap*
  59. -----------------------------------
  60. Add the `_all` parameter to the request to list all snapshots currently stored in the repository:
  61. [source,console]
  62. -----------------------------------
  63. GET /_snapshot/my_backup/_all
  64. -----------------------------------
  65. This request fails if some of the snapshots are unavailable. Use the boolean parameter `ignore_unavailable` to
  66. return all snapshots that are currently available.
  67. Getting all snapshots in the repository can be costly on cloud-based repositories,
  68. both from a cost and performance perspective. If the only information required is
  69. the snapshot names or UUIDs in the repository and the data streams and indices in each snapshot, then
  70. the optional boolean parameter `verbose` can be set to `false` to execute a more
  71. performant and cost-effective retrieval of the snapshots in the repository.
  72. NOTE: Setting `verbose` to `false` omits additional information
  73. about the snapshot, such as metadata, start and end time, number of shards that include the snapshot, and error messages. The default value of the `verbose` parameter is `true`.
  74. [discrete]
  75. [[get-snapshot-detailed-status]]
  76. === Retrieving snapshot status
  77. To retrieve more detailed information about snapshots, use the <<get-snapshot-status-api,get snapshot status API>>. While snapshot request returns only basic information about the snapshot in progress, the snapshot status request returns
  78. complete breakdown of the current state for each shard participating in the snapshot.
  79. // tag::get-snapshot-status-warning[]
  80. [WARNING]
  81. ====
  82. Using the get snapshot status API to return any status results other than the currently running snapshots (`_current`) can be very expensive. Each request to retrieve snapshot status results in file reads from every shard in a snapshot, for each snapshot. Such requests are taxing to machine resources and can also incur high processing costs when running in the cloud.
  83. For example, if you have 100 snapshots with 1,000 shards each, the API request will result in 100,000 file reads (100 snapshots * 1,000 shards). Depending on the latency of your file storage, the request can take extremely long to retrieve results.
  84. ====
  85. // end::get-snapshot-status-warning[]
  86. The following request retrieves all currently running snapshots with
  87. detailed status information:
  88. [source,console]
  89. -----------------------------------
  90. GET /_snapshot/_status
  91. -----------------------------------
  92. By specifying a repository name, it's possible
  93. to limit the results to a particular repository:
  94. [source,console]
  95. -----------------------------------
  96. GET /_snapshot/my_backup/_status
  97. -----------------------------------
  98. If both repository name and snapshot name are specified, the request
  99. returns detailed status information for the given snapshot, even
  100. if not currently running:
  101. [source,console]
  102. -----------------------------------
  103. GET /_snapshot/my_backup/snapshot_1/_status
  104. -----------------------------------
  105. [discrete]
  106. === Monitoring restore operations
  107. The restore process piggybacks on the standard recovery mechanism of
  108. {es}. As a result, standard recovery monitoring services can be used
  109. to monitor the state of restore. When the restore operation starts, the
  110. cluster typically goes into `yellow` state because the restore operation works
  111. by recovering primary shards of the restored indices. After the recovery of the
  112. primary shards is completed, {es} switches to the standard replication
  113. process that creates the required number of replicas. When all required
  114. replicas are created, the cluster switches to the `green` states.
  115. The cluster health operation provides only a high level status of the restore process. It's possible to get more
  116. detailed insight into the current state of the recovery process by using <<indices-recovery, index recovery>> and
  117. <<cat-recovery, cat recovery>> APIs.
  118. [discrete]
  119. [[get-snapshot-stop-snapshot]]
  120. === Stop snapshot and restore operations
  121. To stop a currently running snapshot that was started by mistake or is taking unusually long, use
  122. the <<delete-snapshot-api,delete snapshot API>>.
  123. This operation checks whether the deleted snapshot is currently running. If it is, the delete snapshot operation stops
  124. that snapshot before deleting the snapshot data from the repository.
  125. [source,console]
  126. -----------------------------------
  127. DELETE /_snapshot/my_backup/snapshot_1
  128. -----------------------------------
  129. The restore operation uses the standard shard recovery mechanism. Therefore, any currently running restore operation can
  130. be canceled by deleting data streams and indices that are being restored. Data for all deleted data streams and indices will be removed
  131. from the cluster as a result of this operation.
  132. [discrete]
  133. [[get-snapshot-cluster-blocks]]
  134. === Effect of cluster blocks on snapshot and restore
  135. Many snapshot and restore operations are affected by cluster and index blocks. For example, registering and unregistering
  136. repositories require global metadata write access. The snapshot operation requires that all indices, backing indices, and their metadata (including
  137. global metadata) are readable. The restore operation requires the global metadata to be writable. However,
  138. the index level blocks are ignored during restore because indices are essentially recreated during restore.
  139. A repository content is not part of the cluster and therefore cluster blocks do not affect internal
  140. repository operations such as listing or deleting snapshots from an already registered repository.