Managing backups in Managed Service for MySQL®
You can create backups and restore clusters from existing backups, including point-in-time recovery. For more information, see Backups.
Managed Service for MySQL® also creates automatic daily backups. You can set the backup start time and retention period.
Getting a list of backups
To get a list of cluster backups:
- Go to the folder page
and select Managed Service for MySQL. - Click the name of the cluster you need and select the
Backups tab.
To get a list of all backups in a folder:
- Go to the folder page
and select Managed Service for MySQL. - In the left-hand panel, select
Backups.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To get a list of MySQL® cluster backups available in the default folder, run the 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 put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
To get a list of cluster backups:
-
Use the Cluster.listBackups method and make a request, e.g., via cURL
:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-mysql/v1/clusters/<cluster_ID>/backups'
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
-
To get a list of backups for all the clusters in a folder:
-
Use the Backup.list method and make a request, e.g., via cURL
: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 request the folder ID with a list of folders in the cloud.
-
View the server response to make sure the request was successful.
-
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
To get a list of cluster backups:
-
Use the ClusterService/ListBackups call and make a 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.ListBackups
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
-
To get a list of backups for all the clusters in a folder:
-
Use the BackupService/List call and make a 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.List
You can request the folder ID with a list of folders in the cloud.
-
View the server response to make sure the request was successful.
-
Getting information about backups
To get information about the backup of an existing cluster:
- Go to the folder page
and select Managed Service for MySQL. - Click the name of the cluster you need and select the
Backups tab.
To get information about the backup of a previously deleted cluster:
- Go to the folder page
and select Managed Service for MySQL. - In the left-hand panel, select
Backups.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To get information about a MySQL® cluster backup, run the command:
yc managed-mysql backup get <backup_ID>
You can retrieve the backup ID with a list of backups.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Backup.get method and make a request, e.g., via cURL
: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 together with a list of backups.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the BackupService/Get call and make a 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.Get
You can get the backup ID together with a list of backups.
-
View the server response to make sure the request was successful.
Creating a backup
- Go to the folder page
and select Managed Service for MySQL. - Click the name of the cluster you need 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 command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To create a cluster backup:
-
View a description of the CLI command to create a MySQL® cluster backup:
yc managed-mysql cluster backup --help
-
Request a backup to be created by specifying the cluster name or ID:
yc managed-mysql cluster backup <cluster_name_or_ID>
You can get the cluster ID and name with a list of clusters.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.backup method and make a request, e.g., via cURL
: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 get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService/Backup call and make a 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.Backup
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
Warning
While you are creating your backup, the cluster performance might degrade.
In single-host clusters, you create a backup by reading data from the master host, whereas in multi-host clusters — from one of the replicas. At the same time, you can specify host priorities when creating backups.
Restoring clusters from backups
For a new cluster, you should set all the parameters that are required at creation, except for the cluster type.
To restore an existing cluster from a backup:
-
Go to the folder page
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. -
Set up the new cluster. You can select a folder for the new cluster from the Folder list.
-
To restore the cluster to a particular point in time after creating this backup (Point-in-Time-Recovery), configure Date and time of recovery (UTC) accordingly.
If you do not change the setting, the cluster will be restored to the state when the backup was completed.
-
Click Restore cluster.
To restore a previously deleted cluster from a backup:
-
Go to the folder page
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 formatted as
<cluster_ID>:<backup_ID>
. -
Click
for the backup you need and click Restore cluster. -
Set up the new cluster. You can select a folder for the new cluster from the Folder list.
-
To restore the cluster to a particular point in time after creating this backup, configure Date and time of recovery (UTC) accordingly. You can enter the date manually or select it from the drop-down calendar.
If you do not change the setting, the cluster will be restored to the state when the backup was completed.
-
Click Restore cluster.
Managed Service for MySQL® will launch the operation to create a cluster from the backup.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To restore a cluster from a backup:
-
View a description of the CLI restore MySQL® cluster command:
yc managed-mysql cluster restore --help
-
Getting a list of available MySQL® cluster backups:
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 | | ... | +--------------------------+---------------------+----------------------+---------------------+
The backup completion time is shown in the
CREATED AT
column of the list of available backups, inyyyy-mm-dd hh:mm:ss
format (2020-08-10 12:00:00
in the example above). You can restore a cluster to any point in time starting with the point when the backup is created. -
Request the creation of 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=<public_access_to_host> \ --resource-preset=<host_class> \ --disk-size=<storage_size_in_GB> \ --disk-type=<disk_type>
Where:
-
--backup-id
: Backup ID. -
--time
: Time point to restore the MySQL® cluster to, inyyyy-mm-ddThh:mm:ssZ
time format. -
--name
: Cluster name. -
--environment
: Environment:PRESTABLE
: For testing purposes. The prestable environment is similar to the production environment and likewise covered by the SLA, but it is the first to get new functionalities, improvements, and bug fixes. In the prestable environment, you can test compatibility of new versions with your application.PRODUCTION
: For stable versions of your apps.
-
--network-name
: Network name. -
--host
: Host parameters:-
zone-id
: Availability zone. -
subnet-name
: Subnet name. Specify if two or more subnets are created in the selected availability zone. -
assign-public-ip
: Flag used if public access to the host is required,true
orfalse
.
-
-
--resource-preset
: Host class. -
--disk-size
: Storage size in GB. -
--disk-type
: Disk type:network-hdd
network-ssd
*local-ssd
network-ssd-nonreplicated
-
Use Terraform to restore:
- Existing cluster from a backup.
- Cluster created and deleted via the management console, CLI, or API.
To restore a cluster, you will need the backup ID. Get a 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 use the database (
yandex_mdb_mysql_database
) and user (yandex_mdb_mysql_user
) resources: these will be restored from the backup. -
Add a
restore
section to this configuration file:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... restore { backup_id = "<backup_ID>" time = "<time>" } }
In the
time
parameter, specify the time point to restore the MySQL® cluster to inyyyy-mm-ddThh:mm:ss
format starting from the selected backup's creation time.Note
The
time
parameter is optional. If you do not specify it, the cluster will be restored to the state when the recovery process was started. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
Terraform will create a copy of the existing cluster. The databases and users are 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 use the database (
yandex_mdb_mysql_database
) and user (yandex_mdb_mysql_user
) resources: these will be restored from the backup. -
In this configuration file, add a
restore
section with the name of the backup to restore the cluster from:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... restore { backup_id = "<backup_ID>" } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
Terraform will create the new cluster. The databases and users are deployed from the backup.
For more information, see the Terraform provider documentation
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 put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Create a file named
body.json
and add the following contents to it:{ "backupId": "<backup_ID>", "time": "<time>", "folderId": "<folder_ID>", "name": "<cluster_name>", "environment": "<environment>", "networkId": "<network_ID>", "configSpec": { "version": "<PostgreSQL_version>", "resources": { "resourcePresetId": "<host_class>", "diskSize": "<storage_size_in_bytes>", "diskTypeId": "<disk_type>" } }, "hostSpecs": [ { "zoneId": "<availability_zone>", "subnetId": "<subnet_ID>", "assignPublicIp": <public_host_address:_true_or_false> } ] }
Where:
-
backupId
: Backup ID. You can get it with a list of backups. -
time
: Time point to restore the MySQL® cluster to, inyyyy-mm-ddThh:mm:ssZ
time format. -
folderId
: ID of the folder you want to restore the cluster to. You can get the ID with a 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 the SLA, but it is the first to get new functionalities, improvements, and bug fixes. In the prestable environment, you can test compatibility of new versions 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
: Settings for the cluster hosts as an array of elements, one for each host. Each element has the following structure:zoneId
: Availability zone.subnetId
: Subnet ID.assignPublicIp
: Permission to connect to the host from the internet.
-
-
Use the Cluster.restore method and make a request, e.g., via cURL
: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"
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Create a file named
body.json
and add the following contents to 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": <public_host_address:_true_or_false> } ] }
Where:
-
backup_id
: Backup ID. You can get it with a list of backups. -
time
: Time point to restore the MySQL® cluster to, inyyyy-mm-ddThh:mm:ssZ
time format. -
folder_id
: ID of the folder you want to restore the cluster to. You can get the ID with a 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 the SLA, but it is the first to get new functionalities, improvements, and bug fixes. In the prestable environment, you can test compatibility of new versions 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
: Settings for the cluster hosts 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.
-
-
Use the ClusterService/Restore call and make a 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
-
View the server response to make sure the request was successful.
Setting the backup start time
In the management console
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To set the backup start time in an existing cluster, use the following 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 a list of clusters.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
Add a
backup_window_start
block 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.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
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 put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.update method and make a request, e.g., via cURL
: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
updateMask
parameter 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
: List of parameters to update as a single string, separated by commas.In this case, only one parameter is provided.
-
configSpec.backupWindowStart
: Backup window settings.In this parameter, specify the backup start time. Possible values:
hours
: Between0
and23
hours.minutes
: Between0
and59
minutes.seconds
: Between0
and59
seconds.nanos
: Between0
and999999999
nanoseconds.
You can get the cluster ID with a list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService/Update call and make a 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_mask
parameter 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.Update
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings.In this case, only one parameter is provided.
-
config_spec.backup_window_start
: Backup window settings.In this parameter, specify the backup start time. Possible values:
hours
: Between0
and23
hours.minutes
: Between0
and59
minutes.seconds
: Between0
and59
seconds.nanos
: Between0
and999999999
nanoseconds.
You can get the cluster ID with a list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
Setting a retention period for automatic backups
In the management console
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To set a 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 possible values range from 7
to 60
. The default value is 7
.
You can request the cluster ID and name with a list of clusters in the folder.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
For a complete list of available Managed Service for MySQL® cluster configuration fields, see the Terraform provider documentation
. -
To set a retention period for automatic backups, add a
backup_retain_period_days
block 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.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
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 put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.update method and make a request, e.g., via cURL
: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
updateMask
parameter 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
: List of parameters to update as a single string, separated by commas.In this case, only one parameter is provided.
-
configSpec.backupRetainPeriodDays
: Automatic backup retention period.The values range from
7
to60
. The default value is7
.
You can get the cluster ID with a list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService/Update call and make a 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_mask
parameter 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.Update
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings.In this case, only one parameter is provided.
-
config_spec.backup_retain_period_days
: Automatic backup retention period.The values range from
7
to60
. The default value is7
.
You can get the cluster ID with a list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
Setting host priorities when creating backup
The minimum host priority when creating backups is 0
, the maximum is 100
, and the default is 0
. A replicated host with the highest priority serves as the backup source. For more information, see Creating backups.
In the management console
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To set 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 request the host name with a list of cluster hosts, and the cluster name, with a list of clusters in the folder.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.updateHosts method and make a request, e.g., via cURL
: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_specs
is the array of hosts you are prioritizing. One array element contains settings for a single host and has the following structure:updateMask
: List of parameters to update as a single string, separated by commas.hostName
: FQDN of the host being changed.backupPriority
: Host's backup priority, between0
and100
.
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService/UpdateHosts call and make a 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.UpdateHosts
Where
update_host_specs
is the array of hosts you are prioritizing. One array element contains settings for a single host and has the following structure:update_mask
: List of parameters to update as an array ofpaths[]
strings.host_name
: FQDN of the host being changed.backup_priority
: Host's backup priority, between0
and100
.
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.