clean-up-repo-api.asciidoc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. [[clean-up-snapshot-repo-api]]
  2. === Clean up snapshot repository API
  3. ++++
  4. <titleabbrev>Clean up snapshot repository</titleabbrev>
  5. ++++
  6. Triggers the review of a snapshot repository's contents and deletes any stale
  7. data that is not referenced by existing snapshots.
  8. ////
  9. [source,console]
  10. -----------------------------------
  11. PUT /_snapshot/my_repository
  12. {
  13. "type": "fs",
  14. "settings": {
  15. "location": "my_backup_location"
  16. }
  17. }
  18. -----------------------------------
  19. // TESTSETUP
  20. ////
  21. [source,console]
  22. ----
  23. POST /_snapshot/my_repository/_cleanup
  24. ----
  25. [[clean-up-snapshot-repo-api-request]]
  26. ==== {api-request-title}
  27. `POST /_snapshot/<repository>/_cleanup`
  28. [[clean-up-snapshot-repo-api-prereqs]]
  29. ==== {api-prereq-title}
  30. * If the {es} {security-features} are enabled, you must have the `manage`
  31. <<privileges-list-cluster,cluster privilege>> to use this API.
  32. [[clean-up-snapshot-repo-api-desc]]
  33. ==== {api-description-title}
  34. Over time, snapshot repositories can accumulate stale data that is no longer
  35. referenced by existing snapshots.
  36. While this unreferenced data does not negatively impact the performance or
  37. safety of a snapshot repository, it can lead to more storage use than necessary.
  38. You can use the clean up snapshot repository API to detect and delete this
  39. unreferenced data.
  40. [TIP]
  41. ====
  42. Most cleanup operations performed by this API are performed automatically when
  43. a snapshot is deleted from a repository.
  44. If you regularly delete snapshots, calling this API may only reduce your storage
  45. slightly or not at all.
  46. ====
  47. [[clean-up-snapshot-repo-api-path-params]]
  48. ==== {api-path-parms-title}
  49. `<repository>`::
  50. (Required, string)
  51. Name of the snapshot repository to review and clean up.
  52. [[clean-up-snapshot-repo-api-query-params]]
  53. ==== {api-query-parms-title}
  54. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  55. [role="child_attributes"]
  56. [[clean-up-snapshot-repo-api-response-body]]
  57. ==== {api-response-body-title}
  58. `results`::
  59. (object)
  60. Contains statistics for cleanup operations.
  61. +
  62. .Properties of `results`
  63. [%collapsible%open]
  64. ====
  65. `deleted_bytes`::
  66. (integer)
  67. Number of bytes freed by cleanup operations.
  68. `deleted_blobs`::
  69. (integer)
  70. Number of binary large objects (blobs) removed from the snapshot repository
  71. during cleanup operations. Any non-zero value implies that unreferenced blobs
  72. were found and subsequently cleaned up.
  73. ====
  74. [[clean-up-snapshot-repo-api-example]]
  75. ==== {api-examples-title}
  76. [source,console]
  77. ----
  78. POST /_snapshot/my_repository/_cleanup
  79. ----
  80. The API returns the following response:
  81. [source,console-result]
  82. ----
  83. {
  84. "results": {
  85. "deleted_bytes": 20,
  86. "deleted_blobs": 5
  87. }
  88. }
  89. ----
  90. // TEST[s/"deleted_bytes": 20/"deleted_bytes": 0/]
  91. // TEST[s/"deleted_blobs": 5/"deleted_blobs": 0/]
  92. ////
  93. [source,console]
  94. ----
  95. DELETE /_snapshot/my_repository
  96. ----
  97. ////