| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 | [[snapshots-monitor-snapshot-restore]]== Monitor snapshot and restore progress++++<titleabbrev>Monitor snapshot and restore</titleabbrev>++++Use the <<get-snapshot-api,get snapshot API>> or the<<get-snapshot-status-api,get snapshot status API>> to monitor theprogress of snapshot operations. Both APIs support the`wait_for_completion` parameter that blocks the client until theoperation finishes, which is the simplest method of being notifiedabout operation completion.////[source,console]-----------------------------------PUT /_snapshot/my_backup{  "type": "fs",  "settings": {    "location": "my_backup_location"  }}PUT /_snapshot/my_fs_backup{  "type": "fs",  "settings": {    "location": "my_other_backup_location"  }}PUT /_snapshot/my_backup/snapshot_1?wait_for_completion=true-----------------------------------// TESTSETUP////Use the `_current` parameter to retrieve all currently runningsnapshots in the cluster:[source,console]-----------------------------------GET /_snapshot/my_backup/_current-----------------------------------Including a snapshot name in the request retrieves information about a single snapshot:[source,console]-----------------------------------GET /_snapshot/my_backup/snapshot_1-----------------------------------This request retrieves basic information about the snapshot, including start and end time, version of{es} that created the snapshot, the list of included data streams and indices, the current state of thesnapshot and the list of failures that occurred during the snapshot.Similar to repositories, you can retrieve information about multiple snapshots in a single request, and wildcards are supported:[source,console]-----------------------------------GET /_snapshot/my_backup/snapshot_*,some_other_snapshot-----------------------------------Separate repository names with commas or use wildcards to retrieve snapshots from multiple repositories:[source,console]-----------------------------------GET /_snapshot/_allGET /_snapshot/my_backup,my_fs_backupGET /_snapshot/my*/snap*-----------------------------------Add the `_all` parameter to the request to list all snapshots currently stored in the repository:[source,console]-----------------------------------GET /_snapshot/my_backup/_all-----------------------------------This request fails if some of the snapshots are unavailable. Use the boolean parameter `ignore_unavailable` toreturn all snapshots that are currently available.Getting all snapshots in the repository can be costly on cloud-based repositories,both from a cost and performance perspective.  If the only information required isthe snapshot names or UUIDs in the repository and the data streams and indices in each snapshot, thenthe optional boolean parameter `verbose` can be set to `false` to execute a moreperformant and cost-effective retrieval of the snapshots in the repository.NOTE: Setting `verbose` to `false` omits additional informationabout 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`.[discrete][[get-snapshot-detailed-status]]=== Retrieving snapshot statusTo 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 returnscomplete breakdown of the current state for each shard participating in the snapshot.// tag::get-snapshot-status-warning[][WARNING]====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.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.====// end::get-snapshot-status-warning[]The following request retrieves all currently running snapshots withdetailed status information:[source,console]-----------------------------------GET /_snapshot/_status-----------------------------------By specifying a repository name, it's possibleto limit the results to a particular repository:[source,console]-----------------------------------GET /_snapshot/my_backup/_status-----------------------------------If both repository name and snapshot name are specified, the requestreturns detailed status information for the given snapshot, evenif not currently running:[source,console]-----------------------------------GET /_snapshot/my_backup/snapshot_1/_status-----------------------------------[discrete]=== Monitoring restore operationsThe restore process piggybacks on the standard recovery mechanism of{es}. As a result, standard recovery monitoring services can be usedto monitor the state of restore. When the restore operation starts, thecluster typically goes into `yellow` state because the restore operation worksby recovering primary shards of the restored indices. After the recovery of theprimary shards is completed, {es} switches to the standard replicationprocess that creates the required number of replicas. When all requiredreplicas are created, the cluster switches to the `green` states.The cluster health operation provides only a high level status of the restore process. It's possible to get moredetailed insight into the current state of the recovery process by using <<indices-recovery, index recovery>> and<<cat-recovery, cat recovery>> APIs.[discrete][[get-snapshot-stop-snapshot]]=== Stop snapshot and restore operationsTo stop a currently running snapshot that was started by mistake or is taking unusually long, usethe <<delete-snapshot-api,delete snapshot API>>.This operation checks whether the deleted snapshot is currently running. If it is, the delete snapshot operation stopsthat snapshot before deleting the snapshot data from the repository.[source,console]-----------------------------------DELETE /_snapshot/my_backup/snapshot_1-----------------------------------The restore operation uses the standard shard recovery mechanism. Therefore, any currently running restore operation canbe canceled by deleting data streams and indices that are being restored. Data for all deleted data streams and indices will be removedfrom the cluster as a result of this operation.[discrete][[get-snapshot-cluster-blocks]]=== Effect of cluster blocks on snapshot and restoreMany snapshot and restore operations are affected by cluster and index blocks. For example, registering and unregisteringrepositories require global metadata write access. The snapshot operation requires that all indices, backing indices, and their metadata (includingglobal metadata) are readable. The restore operation requires the global metadata to be writable. However,the index level blocks are ignored during restore because indices are essentially recreated during restore.A repository content is not part of the cluster and therefore cluster blocks do not affect internalrepository operations such as listing or deleting snapshots from an already registered repository.
 |