Backup Policy
First, it should be clarified how the backup will be performed. Commonly used methods are:
-
The path.data address written in Elasticsearch's configuration file can be backed up incrementally or at certain intervals as is by system administrators.
bilgi
PRO Access to historical data will always continue with the same ease.
:::
CON Both active and backup disks will continue to grow continuously.
CON When there is a problem with the main disk, a reinstallation will be required to access the data on the backup disk.
-
The server where Elasticsearch is located can be backed up using Raid-0 method or at certain intervals as is.
bilgi
PRO Access to historical data will always continue with the same ease.
:::
PRO When there is a problem with the main disk, the backup disk can be started immediately with network routing.
CON Both active and backup disks will continue to grow continuously.
-
Elasticsearch data can be dumped using Elasticsearch Snapshot API. By setting a snapshot policy, these backup files can be extracted to a specific system address, and then these backup files should be backed up separately to a different server.
bilgi
PRO Access to historical data will always continue with the same ease.
:::
CON Both active and backup disks will continue to grow continuously.
RECOMMENDATION Regardless of which method above is used, after regular backup is set up, backed up logs can be set to automatically delete with Elasticsearch ILM or can be manually deleted as desired using Elasticsearch API.
PRO Work will continue with much lower disk resources on the active server.
CON To access historical data, an application will need to be installed on the backup disk or backups will need to be transferred to a specific server to work.
CON Only the backup disk will continue to grow continuously.
Elasticsearch Manual Backup and Restore
This section explains how to create the Snapshot Lifecycle Management (SLM) policy created for automatic backup of logs on Elasticsearch through cron definition and methods for instant backup and restore.
Variables
Dynamic values and their descriptions in the requests are shown in the table below.
| Variable | Description |
|---|---|
<ELASTICSEARCH_IP_ADDRESS> | Host information of the Elasticsearch cluster. |
<INDEX_KEY> | This value must be unique as it is identifying at the cluster level. Therefore, the same value should be used in all requests. |
Specifying Backup File Location
By adding the path.repo field to the elasticsearch.yml configuration file of all nodes in the cluster, the file location where backup files will be stored is written.
If this information was added to the configuration file later, the node must be restarted.
path:
repo:
- /backups/my_backup_location
Defining Snapshot Repository Information
Repository holds information about where files to be backed up in snapshot operations will be stored.
curl -X PUT "http://<ELASTICSEARCH_IP_ADDRESS>:9200/_snapshot/apinizer-repository-<INDEX_KEY>?pretty" -H 'Content-Type: application/json' -d'
{
"type": "fs",
"settings": {
"location": "/backups/my_backup_location",
"compress": true
}
}
'
Repository Verification Request (Verify Location)
It should be checked whether Elasticsearch has access to the file.
If verification is successful, the list of nodes using the repository is returned. If verification fails, an error is returned from the request.
curl -X POST "http://<ELASTICSEARCH_IP_ADDRESS>:9200/_snapshot/apinizer-repository-<INDEX_KEY>/_verify?pretty"
If automatic backup will be performed, SLM Policy commands should be executed. If backup will be taken at desired times, Instant Backup commands should be executed.