Managing backups in Managed Service for MySQL®
You can create backups and use the existing backups to restore clusters, including to a specific point in time. For more information, see Backups.
Additionally, Managed Service for MySQL® creates automatic daily backups. You can set the backup start time and retention period.
Getting a list of backups
To get the list of cluster backups:
- Navigate to the folder dashboard
and select Managed Service for MySQL. - Click the name of your cluster and open the
Backups tab.
To get the list of all backups in the folder:
- Navigate to the folder dashboard
and select Managed Service for MySQL. - 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 the list of MySQL® cluster backups available in the default folder, run this command:
yc managed-mysql backup list
Result:
+--------------------------+---------------------+----------------------+---------------------+
| ID | CREATED AT | SOURCE CLUSTER ID | STARTED AT |
+--------------------------+---------------------+----------------------+---------------------+
| c9qgo11pud7kb3c******** | 2020-08-10 12:00:00 | c9qgo11pud7k******** | 2020-08-10 11:55:17 |
| ... |
+--------------------------+---------------------+----------------------+---------------------+
-
Get an IAM token for API authentication and save it as an environment variable:
export IAM_TOKEN="<IAM_token>" -
To get the list of 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-mysql/v1/clusters/<cluster_ID>/backups'You can request the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful.
-
-
To get the list of backups for all clusters in the 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-mysql/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 save it as 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 the list of cluster backups:
-
Use the ClusterService/ListBackups call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.ListBackupsYou can request the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful.
-
-
To get the list of backups for all clusters in the folder:
-
Use the BackupService/List call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/backup_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "folder_id": "<folder_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.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 info
To get information about a backup of an existing cluster:
- Navigate to the folder dashboard
and select Managed Service for MySQL. - Click the name of your cluster and open the
Backups tab.
To get information about a backup of a previously deleted cluster:
- Navigate to the folder dashboard
and select Managed Service for MySQL. - 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 MySQL® cluster backup, run this command:
yc managed-mysql backup get <backup_ID>
You can get the backup ID with the list of backups.
-
Get an IAM token for API authentication and set it as 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-mysql/v1/backups/<backup_ID>'You can get the backup ID with the list of backups.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and set it as 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. -
Use the BackupService/Get call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/backup_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "backup_id": "<backup_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.BackupService.GetYou can request the backup ID with the list of backups.
-
Check the server response to make sure your request was successful.
Creating a backup
- Navigate to the folder dashboard
and select Managed Service for MySQL. - Click the name of your cluster and open 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:
-
See the description of the CLI command for creating a MySQL® cluster backup:
yc managed-mysql cluster backup --help -
Send the following request to create a backup, specifying the cluster ID or name:
yc managed-mysql cluster backup <cluster_name_or_ID>You can get the cluster ID and name with the list of clusters.
-
Get an IAM token for API authentication and set it as 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-mysql/v1/clusters/<cluster_ID>:backup'You can request the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and set it as 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. -
Use the ClusterService/Backup call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.BackupYou can request the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful.
Warning
While you are creating your backup, the cluster performance might degrade.
In single-host clusters, backups are created by reading data from the master host, while in multi-host clusters, from one of the replicas. You can also set the host's backup priority.
Restoring a cluster from a backup
For a new cluster, make sure to set all the required parameters except for the cluster type.
Before you begin, assign to your Yandex Cloud account the managed-mysql.restorer role or higher for the backup folder and the new cluster folder.
To restore an existing cluster from a backup:
-
Navigate to the folder dashboard
and select Managed Service for MySQL. -
Click the name of the cluster you need and select the
Backups tab. -
Click
for the backup you need and click Restore cluster. -
Configure the new cluster. You can select a folder for the new cluster from the Folder list.
-
To restore the cluster state to a specific point in time after the backup was created, configure Date and time of recovery (UTC) accordingly.
If you leave this setting as is, the cluster will be restored to the state it had when the backup was completed.
-
Click Restore cluster.
To restore a previously deleted cluster from a backup:
-
Navigate to the folder dashboard
and select Managed Service for MySQL. -
In the left-hand panel, select
Backups. -
Find the backup you need using the backup creation time and cluster ID. The ID column contains IDs in
<cluster_ID>:<backup_ID>format. -
Click
for the backup at hand and click Restore cluster. -
Configure the new cluster. You can select a folder for the new cluster from the Folder list.
-
To restore the cluster state to a specific point in time after the backup was created, configure Date and time of recovery (UTC) accordingly. You can either enter the date manually or select it from the drop-down calendar.
If you leave this setting as is, the cluster will be restored to the state it had when the backup was completed.
-
Click Restore cluster.
Managed Service for MySQL® will initiate the process of creating a new 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:
-
See the description of the CLI command for restoring a MySQL® cluster:
yc managed-mysql cluster restore --help -
Get the list of available MySQL® cluster backups:
yc managed-mysql backup listResult:
+--------------------------+---------------------+----------------------+---------------------+ | ID | CREATED AT | SOURCE CLUSTER ID | STARTED AT | +--------------------------+---------------------+----------------------+---------------------+ | c9qgo11pud7kb3c******** | 2020-08-10 12:00:00 | c9qgo11pud7k******** | 2020-08-10 11:55:17 | | ... | +--------------------------+---------------------+----------------------+---------------------+The
CREATED ATcolumn in the list of available backups shows the backup completion time inyyyy-mm-dd hh:mm:ssformat (2020-08-10 12:00:00in the example above). You can restore your cluster to the state it was in at any point in time after the backup was created. -
Send the following request to create a cluster from a backup:
yc managed-mysql cluster restore \ --backup-id=<backup_ID> \ --time=<time> \ --name=<cluster_name> \ --environment=<environment> \ --network-name=<network_name> \ --host zone-id=<availability_zone>,` `subnet-name=<subnet_name>,` `assign-public-ip=<allow_public_access_to_host> \ --resource-preset=<host_class> \ --disk-size=<storage_size_in_GB> \ --disk-type=<disk_type>Where:
-
--backup-id: Backup ID. -
--time: Point in time to restore the MySQL® cluster to, inyyyy-mm-ddThh:mm:ssZformat. -
--name: Cluster name. -
--environment: Environment: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 the new versions for compatibility with your application.PRODUCTION: For stable versions of your apps.
-
--network-name: Network name. -
--host: Host settings:-
zone-id: Availability zone. -
subnet-name: Subnet name. Specify it if the selected availability zone has two or more subnets. -
assign-public-ip: Flag to set if public access to the host is required,trueorfalse.
-
-
--resource-preset: Host class. -
--disk-size: Storage size, in GB. -
--disk-type: Disk type:network-hddnetwork-ssdlocal-ssdnetwork-ssd-nonreplicatednetwork-ssd-io-m3
-
Use Terraform to restore:
- Existing cluster from a backup.
- Cluster created and then deleted via the management console, CLI, or API.
To restore a cluster, you will need the backup ID. Get the list of available MySQL® cluster backups using the CLI:
yc managed-mysql backup list
Result:
+--------------------------+---------------------+----------------------+---------------------+
| ID | CREATED AT | SOURCE CLUSTER ID | STARTED AT |
+--------------------------+---------------------+----------------------+---------------------+
| c9qgo11pud7kb3c******** | 2020-08-10 12:00:00 | c9qgo11pud7k******** | 2020-08-10 11:55:17 |
| ... |
+--------------------------+---------------------+----------------------+---------------------+
To restore an existing cluster from a backup:
-
Create a Terraform configuration file for the new cluster.
Do not specify database (
yandex_mdb_mysql_database) and user (yandex_mdb_mysql_user) resources as they will be restored from the backup. -
Add the
restoresection to the configuration file:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... restore { backup_id = "<backup_ID>" time = "<time>" } }In the
timeparameter, specify the point in time to which the MySQL® cluster's state should be restored, starting from the selected backup's creation time, inyyyy-mm-ddThh:mm:ssformat.Note
The
timeparameter is optional. If you skip it, the cluster state will be restored to the point in time when the recovery process was initiated. -
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
Terraform will create a copy of the existing cluster. The databases and users will be deployed from the selected backup.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts block to the cluster description, for example:
resource "yandex_mdb_mysql_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
To restore a previously deleted cluster from a backup:
-
Create a Terraform configuration file for the new cluster.
Do not specify database (
yandex_mdb_mysql_database) and user (yandex_mdb_mysql_user) resources as they will be restored from the backup. -
In this configuration file, add the
restoresection with the name of the backup to restore the data from:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... restore { backup_id = "<backup_ID>" } } -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
Terraform will create the new cluster. The databases and users will be deployed from the backup.
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts block to the cluster description, for example:
resource "yandex_mdb_mysql_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
-
Get an IAM token for API authentication and set it as an environment variable:
export IAM_TOKEN="<IAM_token>" -
Create a file named
body.jsonand paste the following code into it:{ "backupId": "<backup_ID>", "time": "<time>", "folderId": "<folder_ID>", "name": "<cluster_name>", "environment": "<environment>", "networkId": "<network_ID>", "configSpec": { "version": "<MySQL®_version>", "resources": { "resourcePresetId": "<host_class>", "diskSize": "<storage_size_in_bytes>", "diskTypeId": "<disk_type>" } }, "hostSpecs": [ { "zoneId": "<availability_zone>", "subnetId": "<subnet_ID>", "assignPublicIp": <allow_public_access_to_host> } ] }Where:
-
backupId: Backup ID. You can get it with the list of backups. -
time: Point in time to restore the MySQL® cluster to, inyyyy-mm-ddThh:mm:ssZformat. -
folderId: ID of the folder where you want to restore the cluster. You can get the folder ID with the list of folders in the cloud. -
name: Cluster name. -
environment: Environment: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 the new versions for compatibility with your application.PRODUCTION: For stable versions of your apps.
-
networkId: Network ID. -
configSpec: Cluster settings:-
version: MySQL® version. -
resources: Cluster resources:resourcePresetId: Host class.diskSize: Disk size, in bytes.diskTypeId: Disk type.
-
-
hostSpecs: Cluster host settings as an array of elements, one per host. Each element has the following structure:zoneId: Availability zone.subnetId: Subnet ID.assignPublicIp: Permission to connect to the host from the internet,trueorfalse.
-
-
Call the Cluster.restore 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-mysql/v1/clusters:restore' \ --data "@body.json" -
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and save it as 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. -
Create a file named
body.jsonand paste the following code into it:{ "backup_id": "<backup_ID>", "time": "<time>", "folder_id": "<folder_ID>", "name": "<cluster_name>", "environment": "<environment>", "network_id": "<network_ID>", "config_spec": { "version": "<MySQL®_version>", "resources": { "resource_preset_id": "<host_class>", "disk_size": "<storage_size_in_bytes>", "disk_type_id": "<disk_type>" } }, "host_specs": [ { "zone_id": "<availability_zone>", "subnet_id": "<subnet_ID>", "assign_public_ip": <allow_public_access_to_host> } ] }Where:
-
backup_id: Backup ID. You can get it with the list of backups. -
time: Point in time to restore the MySQL® cluster to, inyyyy-mm-ddThh:mm:ssZformat. -
folder_id: ID of the folder where you want to restore the cluster. You can request the ID with the list of folders in the cloud. -
name: Cluster name. -
environment: Environment: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 the new versions for compatibility with your application.PRODUCTION: For stable versions of your apps.
-
network_id: Network ID. -
config_spec: Cluster settings:-
version: MySQL® version. -
resources: Cluster resources:resource_preset_id: Host class.disk_size: Disk size, in bytes.disk_type_id: Disk type.
-
-
host_specs: Cluster host settings as an array of elements, one for each host. Each element has the following structure:zone_id: Availability zone.subnet_id: Subnet ID.assign_public_ip: Permission to connect to the host from the internet,trueorfalse.
-
-
Use the ClusterService/Restore call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.Restore \ < body.json -
Check 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 for an existing cluster, use the update command:
yc managed-mysql cluster update <cluster_name_or_ID> \
--backup-window-start=<time>
Where backup-window-start is the backup start UTC time in HH:MM:SS format.
You can get the cluster ID and name with the list of clusters.
-
Open the current Terraform configuration file describing your infrastructure.
For information on how to create this file, see Creating a cluster.
-
Add the
backup_window_startsection to the Managed Service for MySQL® cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... backup_window_start { hours = <hour> minutes = <minute> } }Where:
hours: Backup start hour (UTC).minutes: Backup start minute (UTC).
-
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts block to the cluster description, for example:
resource "yandex_mdb_mysql_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
-
Get an IAM token for API authentication and save it as 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-mysql/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 provide only one setting.
-
configSpec.backupWindowStart: Backup window settings.In this setting, specify the backup start time. Allowed values:
hours: Between0and23hours.minutes: Between0and59minutes.seconds: Between0and59seconds.nanos: Between0and999999999nanoseconds.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and set it as 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. -
Use the ClusterService/Update call and send the following request, e.g., via gRPCurl
: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/mysql/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.mysql.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array of strings (paths[]).Here, we provide only one setting.
-
config_spec.backup_window_start: Backup window settings.In this setting, specify the backup start time. Allowed values:
hours: Between0and23hours.minutes: Between0and59minutes.seconds: Between0and59seconds.nanos: Between0and999999999nanoseconds.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check 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 the retention period for automatic backups, provide the required value in the --backup-retain-period-days argument of the cluster update command:
yc managed-mysql cluster update <cluster_name_or_ID> \
--backup-retain-period-days=<retention_period_in_days>
The valid values range from 7 to 60. The default value is 7.
You can get the cluster ID and name with the list of clusters in the folder.
-
Open the current Terraform configuration file describing your infrastructure.
For information on how to create this file, see Creating a cluster.
For a complete list of Managed Service for MySQL® cluster configuration fields you can update, see this Terraform provider article.
-
To set the retention period for automatic backups, add the
backup_retain_period_dayssection to the Managed Service for MySQL® cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... backup_window_start: <retention_period_in_days> } -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts block to the cluster description, for example:
resource "yandex_mdb_mysql_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
-
Get an IAM token for API authentication and save it as 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-mysql/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.backupRetainPeriodDays", "configSpec": { "backupRetainPeriodDays": <retention_period_in_days> } }'Where:
-
updateMask: Comma-separated list of settings you want to update.Here, we provide only one setting.
-
configSpec.backupRetainPeriodDays: Automatic backup retention period.The valid values range from
7to60. The default value is7.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and set it as 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. -
Use the ClusterService/Update call and send the following request, e.g., via gRPCurl
: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/mysql/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.mysql.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array of strings (paths[]).Here, we provide only one setting.
-
config_spec.backup_retain_period_days: Automatic backup retention period.The valid values range from
7to60. The default value is7.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
Setting a host's backup priority
The minimum value of the host's backup priority is 0, and the maximum, 100. The default value is 0. The replica host with the highest priority is selected as the backup source. For more information, see Creating 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 backup priority for a selected host, run this command:
yc managed-mysql host update <host_name> \
--cluster-name=<cluster_name> \
--backup-priority=<host_backup_priority>
Where backup-priority is the host's backup priority, between 0 and 100.
You can get the host name with the list of cluster hosts, and the cluster name, with the list of clusters in the folder.
-
Get an IAM token for API authentication and set it as an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.updateHosts 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-mysql/v1/clusters/<cluster_ID>/hosts:batchUpdate' \ --data '{ "updateHostSpecs": [ { "updateMask": "backupPriority", "hostName": "<host_FQDN>", "backupPriority": "<host_backup_priority>" } ] }'Where
update_host_specsis the array of hosts you are prioritizing. Each array element contains the configuration for a single host and has the following structure:updateMask: Comma-separated list of settings you want to update.hostName: FQDN of the host you are updating.backupPriority: Host's backup priority, between0and100.
You can request the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and set it as 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. -
Use the ClusterService/UpdateHosts call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_host_specs": [ { "update_mask": { "paths": [ "backup_priority" ] }, "host_name": "<host_FQDN>", "backup_priority": "<host_backup_priority>" } ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.UpdateHostsWhere
update_host_specsis the array of hosts you are prioritizing. Each array element contains the configuration for a single host and has the following structure:update_mask: List of settings you want to update as an array of strings (paths[]).host_name: FQDN of the host you are updating.backup_priority: Host's backup priority, between0and100.
You can request the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful.