Elasticsearch: Is it safe to delete snapshots?

Quick answer : yes!

Deleting snapshots is safe because each snapshot is logically independent.

Learn how and why keep reading.

Elasticsearch uses incremental snapshots to enable you to backup and restore data efficiently. You can find out how it works in this great article " Elasticsearch: How do incremental snapshots work? "

Here are some thoughts on snapshots.

1. Delete the snapshot

When you delete a snapshot in Elasticsearch, only the segments specific to that particular snapshot are deleted. Any segments still in use by other snapshots in the repository are preserved. This ensures that deleting one snapshot does not affect the integrity of other snapshots.

Each snapshot is also logically independent. When you delete a snapshot, Elasticsearch only deletes the segments specific to that snapshot. Elasticsearch will not delete segments that are still in use by other snapshots in the repository.

Read the article " Elasticsearch: How do incremental snapshots work? "

2. Adjust the snapshot speed

To tune snapshot speed, Elasticsearch provides a configuration parameter called max_snapshot_bytes_per_sec. By adjusting this parameter, you can set the maximum rate at which snapshots are created per node. The default value is 40 MB per second, but can be modified according to your specific requirements. It's worth noting that hosting services have recovery settings in place, which may further limit the snapshot rate.

Shared file system repository | Elasticsearch Guide [8.8] | Elastic

3. Automated snapshots

Elasticsearch provides a convenient way to automate snapshots using the Snapshot Lifecycle Management (SLM) policy. SLM allows you to define policies that automatically capture snapshots and manage their retention period. This feature is available for free and provides a seamless way to handle backups without manual intervention. You can refer to the Elasticsearch documentation for more details on using the SLM API.

Create or update snapshot lifecycle policy API | Elasticsearch Guide [8.8] | Elastic

Read more: Elasticsearch: Snapshot Lifecycle Management .

4. Delete the repository

Repositories in Elasticsearch act as pointers to snapshots. Deleting a repository does not affect the snapshot itself. You can add or remove repositories without affecting the snapshots stored in them.

Delete snapshot repository API | Elasticsearch Guide [8.8] | Elastic

5. Different clusters use the same repository

You can use the same repository for different clusters. However, when doing so, one of the clusters must be designated as read-only. This precaution is necessary to avoid potential conflicts and maintain the integrity of the snapshot. For example, during index migration from one cluster to another, it is recommended to create a read-only repository on the new cluster and restore the snapshot of the old cluster to the new cluster.

Elasticsearch's incremental snapshot feature provides a reliable and efficient way to backup and restore data. By understanding its key aspects and taking advantage of the tools available, you can ensure the security and accessibility of your Elasticsearch indexes.

To restore a snapshot, its repository must be registered and available to the new cluster. If the original cluster still has write access to the repository, register the repository as read-only. This prevents multiple clusters from writing to the repository at the same time and corrupting the repository's contents. It also prevents Elasticsearch from caching the contents of the repository, which means changes made by other clusters will be immediately visible.

Guess you like

Origin blog.csdn.net/UbuntuTouch/article/details/131426159