Managing backups in Managed Service for ClickHouse®
You can create backups and restore clusters from existing backups.
Moreover, Managed Service for ClickHouse® creates automatic daily backups. You can set the backup start time and retention period.
Creating a backup
Warning
The system uses random replica hosts to create backups. If cluster hosts lack data consistency, restoring such a cluster from a backup does not guarantee complete data recovery. For more information, see Backups.
- In the management console
, select the folder the cluster is in. - Go to Managed Service for ClickHouse.
- Click the cluster name and select the Backups tab.
- Click Create backup.
The service will start creating a backup without an additional confirmation.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To create a cluster backup:
-
View the description of the CLI command for creating a ClickHouse® backup:
yc managed-clickhouse cluster backup --help -
Send a request to create a cluster backup, specifying the cluster name or ID:
yc managed-clickhouse cluster backup <cluster_name_or_ID>You can get the cluster name and ID with the list of clusters in the folder.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.Backup method, e.g., via the following cURL
request:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>:backup'You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.Backup method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.BackupYou can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
Warning
While you are creating your backup, the cluster performance might degrade.
Restoring a cluster from a backup
When you restore a cluster from a backup, you create a new cluster with the backup data. If your cloud lacks resources to create such a cluster, you will not be able to restore your data from the backup. The average backup recovery speed is 10 MBps per database core.
You can restore an individual shard or the whole cluster.
Before you begin, assign the following roles to your Yandex Cloud account:
- managed-clickhouse.restorer or higher for the backup folder and the new cluster folder.
- iam.serviceAccounts.user or higher if restoring a cluster assigned to a service account.
Important
When restoring a backup to a cluster without any ZooKeeper hosts, all the ReplicatedMergeTree tables will be converted to simple MergeTree tables. Converted tables will contain the same data. For more information, see this ClickHouse® guide
To restore an existing cluster from a backup:
-
In the management console
, select the folder where you want to restore a cluster. -
Go to Managed Service for ClickHouse.
-
Click the cluster name and select the Backups tab.
-
Click
for the backup you need and click Restore cluster. -
Update the new cluster settings, if required. You can select a folder for the new cluster from the Folder list.
To restore a single shard, make sure to leave only that particular shard checked under Shards. Uncheck the rest of the shards.
To restore the whole cluster, leave all shards checked under Shards.
You can set up a separate configuration for each shard you restore.
-
Click Restore cluster.
To restore a previously deleted cluster from a backup:
-
In the management console
, select the folder where you want to restore a cluster. -
Go to Managed Service for ClickHouse.
-
In the left-hand panel, select
Backups. -
Click
for the backup and click Restore cluster. -
Update the new cluster settings, if required. You can select a folder for the new cluster from the Folder list.
To restore a single shard, make sure to leave only that particular shard checked under Shards. Uncheck the rest of the shards.
To restore the whole cluster, leave all shards checked under Shards.
You can set up a separate configuration for each shard you restore.
-
Click Restore cluster.
Managed Service for ClickHouse® will start creating the cluster from the backup.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To restore a cluster from a backup:
-
View the description of the CLI command for restoring a ClickHouse® cluster:
yc managed-clickhouse cluster restore --help -
Get the list of available ClickHouse® cluster backups:
yc managed-clickhouse backup list+----------------------+---------------------+----------------------+---------------------+-------------+-------+-----------+ | ID | CREATED AT | SOURCE CLUSTER ID | STARTED AT | SHARD NAMES | SIZE | TYPE | +----------------------+---------------------+----------------------+---------------------+-------------+-------+-----------+ | mdb29m1kk9v2******** | 2023-12-08 00:09:17 | c9qud5etkq19******** | 2023-12-08 00:08:06 | shard1 | 30 KB | AUTOMATED | | ... | | | | | | | +----------------------+---------------------+----------------------+---------------------+-------------+-------+-----------+ -
To restore a cluster, run the command below considering the backup type:
-
If the backup was created for all cluster shards at once, which is the backup option currently used, provide a single backup ID in the command:
yc managed-clickhouse cluster restore \ --backup-id=<cluster_ID>:<backup_ID> \ --name=<cluster_name> \ --environment=<environment> \ --network-name=<network_name> \ --host type=<host_type>,` `zone-id=<availability_zone>,` `subnet-id=<subnet_ID> \ --shard name=<shard_name>,` `weight=<shard_weight> \ --clickhouse-disk-size=<storage_size_in_GB> \ --clickhouse-disk-type=<disk_type> \ --clickhouse-resource-preset=<host_class>Where:
-
--backup-id: Cluster and backup IDs. -
--name: Cluster name. -
--environment: Environment:PRODUCTION: For stable versions of your applications.PRESTABLE: For testing purposes. The prestable environment is similar to the production environment and likewise covered by an SLA, but it is the first to get new features, improvements, and bug fixes. In the prestable environment, you can test new versions for compatibility with your application.
-
--network-name: Network name. -
--host: Host settings:type: Host type,clickhouseorzookeeper.zone-id: Availability zone.subnet-id: Subnet ID. Specify it if the selected availability zone has two or more subnets.
-
--shard: Shard parameters:name: Shard name.weight: Shard weight. The minimum value is0.
To restore a single cluster shard, only specify the parameters for the shard to restore. The shard name must match its name in the source cluster.
To restore the whole cluster, you may skip shard parameters.
-
--resource-preset: Host class. -
--disk-size: Storage size, in GB. -
--disk-type: Disk type:network-hddnetwork-ssdlocal-ssdnetwork-ssd-nonreplicatednetwork-ssd-io-m3
-
-
If separate backups were created for each cluster shard, which is the legacy backup option, provide the backup IDs of all the cluster shards to restore the whole cluster:
yc managed-clickhouse cluster restore \ --backup-id=<list_of_backup_IDs_for_all_shards> \ ...
-
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.Restore method, e.g., via the following cURL
request:-
Create a file named
body.jsonand paste the following code into it:{ "backupId": "<cluster_ID>:<backup_ID>", "additionalBackupIds": [ <list_of_additional_backup_IDs> ], "name": "<cluster_name>", "environment": "<environment>", "configSpec": { <cluster_configuration> }, "hostSpecs": [ { "type": "<host_type>", "zoneId": "<availability_zone>", "subnetId": "<subnet_ID>", "shardName": "<shard_name>", "assignPublicIp": <public_access_to_host> }, { <similar_settings_for_host_2> }, { ... }, { <similar_settings_for_host_N> } ], "shardSpecs: [ { "name": "<shard_name>", "configSpec": { "clickhouse": { "weight": "<shard_weight>" } } ], "folderId": "<folder_ID>", "networkId": "<network_ID>", "serviceAccountId": "<service_account_ID>", "securityGroupIds": [ <list_of_security_group_IDs> ], "deletionProtection": <cluster_deletion_protection> }Where:
-
backupId: Cluster and backup IDs.This will restore your cluster as a whole.
-
additionalBackupIds: Array of additional backup IDs. Use this parameter if separate backups were created for each shard (the legacy backup option).This will restore the shards for which those backups were created. To restore the whole cluster, provide backup IDs for all cluster shards.
-
name: Cluster name. -
environment: Environment:PRODUCTION: For stable versions of your applications.PRESTABLE: For testing purposes. The prestable environment is similar to the production environment and likewise covered by an SLA, but it is the first to get new features, improvements, and bug fixes. In the prestable environment, you can test new versions for compatibility with your application.
-
configSpec: ClickHouse® cluster configuration. For a detailed description of the parameters, see the Cluster.restore method description. -
hostSpecs: Array of settings for the new hosts. Each array element contains the configuration for a single host and has the following structure:type: Host type.zoneId: Availability zone.subnetId: Subnet ID.shardName: Shard name.assignPublicIp: Internet access to the host via a public IP address,trueorfalse.
-
shardSpecs: Array of settings of the shards to restore:name: Shard name. The value must match the shard name in the source cluster.configSpec.clickhouse.weight: Shard weight. The minimum value is0.
To restore a single cluster shard, only specify the parameters for the shard to restore.
To restore the whole cluster, you may skip this parameter.
You can set up a separate configuration for each shard you restore.
-
folderId: ID of the folder where you want to create your cluster. -
networkId: ID of the network where you want to deploy your cluster. -
serviceAccountId: Service account ID. -
securityGroupIds: Array of security group IDs. -
deletionProtection: Option to manage cluster protection against accidental deletion.Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
You can request the cluster ID and backup ID together with the list of backups in the folder.
-
-
Run this query:
curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters:restore' \ --data "@body.json"
-
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.Restore method, e.g., via the following gRPCurl
request:-
Create a file named
body.jsonand paste the following code into it:{ "backup_id": "<cluster_ID>:<backup_ID>", "additional_backup_ids": [ <list_of_additional_backup_IDs> ], "name": "<cluster_name>", "environment": "<environment>", "config_spec": { <cluster_configuration> }, "host_specs": [ { "type": "<host_type>", "zone_id": "<availability_zone>", "subnet_id": "<subnet_ID>", "shard_name": "<shard_name>", "assign_public_ip": <public_access_to_host> }, { <similar_settings_for_host_2> }, { ... }, { <similar_settings_for_host_N> } ], "shard_specs: [ { "name": "<shard_name>", "config_spec": { "clickhouse": { "weight": "<shard_weight>" } } ], "folder_id": "<folder_ID>", "network_id": "<network_ID>", "service_account_id": "<service_account_ID>", "security_group_ids": [ <list_of_security_group_IDs> ], "deletion_protection": <cluster_deletion_protection> }Where:
-
backup_id: Cluster and backup IDs.This will restore your cluster as a whole.
-
additional_backup_ids: Array of additional backup IDs. Use this parameter if separate backups were created for each shard (the legacy backup option).This will restore the shards for which those backups were created. To restore the whole cluster, provide backup IDs for all cluster shards.
-
name: Cluster name. -
environment: Environment:PRODUCTION: For stable versions of your applications.PRESTABLE: For testing purposes. The prestable environment is similar to the production environment and likewise covered by an SLA, but it is the first to get new features, improvements, and bug fixes. In the prestable environment, you can test new versions for compatibility with your application.
-
config_spec: ClickHouse® cluster configuration. For a detailed description of the parameters, see the ClusterService/Restore call description. -
host_specs: Array of settings for the new hosts. Each array element contains the configuration for a single host and has the following structure:type: Host type.zone_id: Availability zone.subnet_id: Subnet ID.shard_name: Shard name.assign_public_ip: Internet access to the host via a public IP address,trueorfalse.
-
shard_specs: Array of settings of the shards to restore:name: Shard name. The value must match the shard name in the source cluster.config_spec.clickhouse.weight: Shard weight. The minimum value is0.
To restore a single cluster shard, only specify the parameters for the shard to restore.
To restore the whole cluster, you may skip this parameter.
You can set up a separate configuration for each shard you restore.
-
folder_id: ID of the folder where you want to create your cluster. -
network_id: ID of the network where you want to deploy your cluster. -
service_account_id: Service account ID. -
security_group_ids: Array of security group IDs. -
deletion_protection: Option to manage cluster protection against accidental deletion.Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
You can request the cluster ID and backup ID together with the list of backups in the folder.
-
-
Run this query:
grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.Restore \ < body.json
-
-
View the server response to make sure your request was successful.
Getting a list of backups
To get a list of cluster backups:
- In the management console
, select the folder the cluster is in. - Go to Managed Service for ClickHouse.
- Click the cluster name and select the Backups tab.
To get a list of all backups in a folder:
- In the management console
, select the folder the cluster is in. - Go to Managed Service for ClickHouse.
- In the left-hand panel, select
Backups.
These lists contain the following information:
- Backup ID.
- Source shard names.
- Backup size.
- Backup type:
AutomatedorManual. - Backup start time (UTC).
- Backup end time (UTC).
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To get a list of ClickHouse® cluster backups available in the default folder, run this command:
yc managed-clickhouse backup list
+----------------------+---------------------+----------------------+---------------------+-------------+-------+-----------+
| ID | CREATED AT | SOURCE CLUSTER ID | STARTED AT | SHARD NAMES | SIZE | TYPE |
+----------------------+---------------------+----------------------+---------------------+-------------+-------+-----------+
| mdb29m1kk9v2******** | 2023-12-08 00:09:17 | c9qud5etkq19******** | 2023-12-08 00:08:06 | shard1 | 30 KB | AUTOMATED |
| mdb9sds0ast2******** | 2023-12-07 08:17:04 | c9qud5etkq19******** | 2023-12-07 08:15:54 | shard1 | 30 KB | MANUAL |
+----------------------+---------------------+----------------------+---------------------+-------------+-------+-----------+
The table in the command output contains the following information:
- Backup ID.
- Backup end time (UTC).
- ID of the backed up cluster.
- Backup start time (UTC).
- Source shard names.
- Backup size.
- Backup type:
AUTOMATEDorMANUAL.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
To get a list of ClickHouse® cluster backups:
-
Call the Cluster.ListBackups method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/backups'You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
-
-
To get a list of backups for all ClickHouse® clusters in a folder:
-
Call the Backup.List method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/backups' \ --url-query folderId=<folder_ID>You can get the folder ID with the list of folders in the cloud.
-
Check the server response to make sure your request was successful.
-
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
To get a list of ClickHouse® cluster backups:
-
Call the ClusterService.ListBackups method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.ListBackupsYou can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
-
-
To get a list of backups for all ClickHouse® clusters in a folder:
-
Call the BackupService.List method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/backup_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "folder_id": "<folder_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.BackupService.ListYou can get the folder ID with the list of folders in the cloud.
-
Check the server response to make sure your request was successful.
-
Getting backup information
To get information about a backup of an existing cluster:
- In the management console
, select the folder the cluster is in. - Go to Managed Service for ClickHouse.
- Click the cluster name and select the Backups tab.
To get information about a backup of a previously deleted cluster:
- In the management console
, select the folder where the cluster used to reside. - Go to Managed Service for ClickHouse.
- In the left-hand panel, select
Backups.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To get information about a ClickHouse® cluster backup, run this command:
yc managed-clickhouse backup get <cluster_ID>:<backup_ID>
You can get the cluster ID and backup ID with the list of backups.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Backup.Get method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/backups/<cluster_ID>:<backup_ID>'You can get the cluster ID and backup ID with the list of backups.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the BackupService.Get method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/backup_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "backup_id": "<cluster_ID>:<backup_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.BackupService.GetYou can get the cluster ID and backup ID with the list of backups.
-
View the server response to make sure your request was successful.
Setting the backup start time
In the management console
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To set the backup start time, provide the appropriate value in HH:MM:SS format in the --backup-window-start argument of the cluster update command:
yc managed-clickhouse cluster update <cluster_name_or_ID> \
--backup-window-start=<backup_start_time>
You can get the cluster ID and name with the list of clusters in the folder.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.Update method, e.g., via the following cURL
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
updateMaskparameter as a single comma-separated string.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.backupWindowStart", "configSpec": { "backupWindowStart": { "hours": "<hours>", "minutes": "<minutes>", "seconds": "<seconds>", "nanos": "<nanoseconds>" } } }'Where:
-
updateMask: Comma-separated list of settings you want to update.Here, we only specified a single setting,
configSpec.backupWindowStart. -
configSpec.backupWindowStart: Backup start time (UTC):hours: Hours in 24-hour formatminutes: Minutesseconds: Secondsnanos: Nanoseconds
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.Update method, e.g., via the following gRPCurl
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
update_maskparameter as an array ofpaths[]strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.backup_window_start" ] }, "config_spec": { "backup_window_start": { "hours": "<hours>", "minutes": "<minutes>", "seconds": "<seconds>", "nanos": "<nanoseconds>" } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array of strings (paths[]).Here, we only specified a single setting,
config_spec.backup_window_start. -
config_spec.backup_window_start: Backup start time (UTC):hours: Hours in 24-hour formatminutes: Minutesseconds: Secondsnanos: Nanoseconds
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
Setting a retention period for automatic backups
In the management console
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To set a retention period for automatic backups, provide the required value in HH:MM:SS format in the --backup-retain-period-days argument of the cluster update command:
yc managed-clickhouse cluster update <cluster_name_or_ID> \
--backup-retain-period-days=<automatic_backup_retention_period_in_days>
You can get the cluster ID and name with the list of clusters in the folder.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.Update method, e.g., via the following cURL
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
updateMaskparameter as a single comma-separated string.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.backupRetainPeriodDays", "configSpec": { "backupRetainPeriodDays": <number_of_days> } }'Where:
-
updateMask: Comma-separated list of settings you want to update.Here, we only specified a single setting,
configSpec.backupRetainPeriodDays. -
configSpec.backupRetainPeriodDays: New automatic backup retention period, in days.
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.Update method, e.g., via the following gRPCurl
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
update_maskparameter as an array ofpaths[]strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.backup_retain_period_days" ] }, "config_spec": { "backup_retain_period_days": <number_of_days> } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array of strings (paths[]).Here, we only specified a single setting,
config_spec.backup_retain_period_days. -
config_spec.backup_retain_period_days: New automatic backup retention period, in days.
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
Deleting a backup
Warning
You can only delete manual backups.
- In the management console
, select the folder the cluster is in. - Go to Managed Service for ClickHouse.
- Click the cluster name and select the Backups tab.
- Click
for the backup in question and select Delete backup.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To delete a cluster backup:
-
View the description of the CLI command for deleting a ClickHouse® cluster backup:
yc managed-clickhouse backup delete --help -
Send a request to delete a backup, specifying the backup ID:
yc managed-clickhouse backup delete <cluster_ID>:<backup_ID>You can get the cluster ID and backup ID with the list of backups.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Backup.Delete method, for instance, via the following cURL
request:curl \ --request DELETE \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/backups/<cluster_ID>:<backup_ID>'You can get the cluster ID and backup ID with the list of backups.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the BackupService.Delete method, for instance, via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/backup_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "backup_id": "<cluster_ID>:<backup_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.BackupService.DeleteYou can get the cluster ID and backup ID with the list of backups.
-
View the server response to make sure your request was successful.
ClickHouse® is a registered trademark of ClickHouse, Inc