All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Data backup

Last updated:2023-05-31 16:51:40

This topic describes how to back up data from a Kingsoft Cloud Elasticsearch Service (KES) cluster to Kingsoft Cloud Standard Storage Service (KS3) and how to use the backup to restore data. You can use the cluster backup feature in the KES console to enable scheduled daily backup or use scripts to perform manual backup.

KES implements data backup and restore based on [snapshots][snapshots].

Automatic system backup

After you enable the automatic system backup feature for a KES cluster, the system takes snapshots for the KES cluster at the scheduled time every day.

image.png

To enable automatic system backup, perform the following steps:

  1. Activate the KS3 service and establish a bucket for the backup of the target KES cluster.
  2. On the Cluster Management page of the KES console, find the KES cluster to back up and choose Management > Data Backup in the Operation column to go to the Data Backup page.
  3. Turn on Automatic Backup and specify the point in time and bucket for daily backup.
  4. Click Submit.

Note: This operation automatically registers a snapshot repository named SystemAutoBackup in KES. All data is backed up in the first backup and only incremental data is backed up in subsequent backups.

Snapshot restore from automatic system backup

The operations of restoring snapshots from automatic system backup are the same as those of restoring snapshots from manual backup. The only difference is that the name of the snapshot repository for automatic system backup is SystemAutoBackup. You can select the snapshots of a specific date from the snapshot list for automatic system backup based on the date in the snapshot name and restore the snapshots as needed.

To view the snapshot list for automatic system backup, run the following command:

GET /_snapshot/SystemAutoBackup/_all

From the returned snapshot list, select the snapshot snap_20191202_000543 of the time 2019-12-02T0:05:43 and restore two indexes from the snapshot.

POST /_snapshot/SystemAutoBackup/snap_20191202_150405/_restore
{
  "indices": "my_index_1,my_index_2",
  "include_global_state": false,
  "rename_pattern": "(.+)",
  "rename_replacement": "restored_$1"   // The new index names after restore are restored_my_index_1 and restored_my_index_2.
}

Manual backup

If you prefer a more flexible backup method than automatic backup, configure and perform manual backup. Manual backup and automatic backup are independent of each other.

Before you configure manual backup, make sure that you have activated the KS3 service and established a bucket for the backup.

All the following operations are completed by sending HTTP requests to KES.

Create a snapshot repository

Create a snapshot repository named my_repo.

PUT /_snapshot/my_repo
{
  "type": "s3",
  "settings":{
    "bucket": "my_bucket_name",
    "base_path": "my_path",
    "region": "xxxxx",
    "endpoint": "xxxxx.ksyun.com",
    "access_key": "xxxxxx",
    "secret_key": "xxxxxx"
  }
}

The parameters in the preceding request are as follows:

  • bucket: the name of the bucket that you create in KS3.
  • base_path: the path for storing backup data in the bucket.
  • region: the region where your KES instance is deployed. Set this parameter to the English region name in the KS3 endpoint.
  • endpoint: the KS3 endpoint corresponding to the region where your KES cluster is deployed. Set this parameter to the internal endpoint in KS3 endpoint.
  • access_key: the AccessKey of your Kingsoft Cloud account.
  • secret_key: The SecretKey of your Kingsoft Cloud account.

View snapshot repositories

To view the snapshot repository list, run the following command:

GET /_snapshot

To view a specific snapshot repository, run the following command:

GET /_snapshot/my_repo

Delete a snapshot repository

DELETE /_snapshot/my_repo

This operation does not delete data in KS3.

Create a snapshot

You can create a snapshot to back up data once in KES.

To create a snapshot for all indexes and name the snapshot my_snap1, run the following command:

PUT /_snapshot/my_repo/my_snap1

To create a snapshot for specific indexes and name the snapshot my_snap2, run the following commands:

PUT /_snapshot/my_repo/my_snap2
{
  "indices": "my_index_1,my_index_2"
}

Snapshot management and restore

View snapshots

To view the snapshot list, run the following command:

GET /_snapshot/my_repo/_all

To view a specific snapshot, run the following command:

GET /_snapshot/my_repo/my_snap1

View creating snapshots

To view the snapshots that are being created, run the following command:

GET /_snapshot/my_repo/_current

To view the progress of snapshot creation and shard backup, run the following commands:

GET /_snapshot/_status
GET /_snapshot/my_repo/_status
GET /_snapshot/my_repo/my_snap1/_status
GET /_snapshot/my_repo/my_snap1,my_snap2/_status

Delete a snapshot

To delete a created or creating snapshot, run the following command. This operation does not delete data in KS3:

DELETE /_snapshot/my_repo/my_snap1

Restore data from a snapshot

When you restore data from a snapshot, the data backed up in KS3 is imported to KES and new indexes are created for the data. If an index with the same name already exists in KES, data restore fails.

To restore all data from the snapshot my_snap1, run the following command:

POST /_snapshot/my_repo/my_snap1/_restore

To restore data of a specific index and create a new index for the restored data, run the following command:

POST /_snapshot/my_repo/my_snap1/_restore
{
  "indices": "my_index_1",
  "include_global_state": false,
  "rename_pattern": "(.+)",
  "rename_replacement": "restored_$1"   // The new index name after restore is restored_my_index_1.
}

View the restore status

To view the status and progress of index restore, run the following command:

GET /restored_my_index_1/_recovery

Cancel restore

To cancel the restore of specific data, delete the index created for the restored data. You can run the following command to cancel restore:

DELETE /restored_my_index_1
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback