Managing backups in Yandex Managed Service for Sharded PostgreSQL
Note
The service is at the Preview stage.
You can create backups and use existing backups to restore your clusters.
Managed Service for Sharded PostgreSQL automatically takes a daily backup as well. You can specify the start time and configure the retention period for automatic backups.
Restoring a cluster from a backup
Warning
For clusters running an unsupported DBMS version, restoring from backups is not available.
To restore an existing cluster from a backup:
-
Navigate to the folder dashboard
and select Yandex Managed Service for Sharded PostgreSQL. -
Click the name of your cluster and select the
Backups tab. -
Click
in the row with the backup you need and select Restore cluster. -
Configure the new cluster.
You can select a folder for the new cluster in the Folder field.
-
Click Restore cluster.
To restore a deleted cluster from a backup:
-
Navigate to the folder dashboard
and select Yandex Managed Service for Sharded PostgreSQL. -
In the left-hand panel, select
Backups. -
Click
in the row with the backup you need and select Restore cluster. -
Configure the new cluster.
You can select a folder for the new cluster in the Folder field.
-
Click Restore cluster.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI 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 options.
To restore a cluster from a backup:
-
View the description of the CLI command for restoring a cluster:
yc managed-sharded-postgresql cluster restore --help -
Create a cluster from a backup (the example does not include all the available flags):
yc managed-sharded-postgresql cluster restore \ --backup-id <backup_ID> \ --time <time_point_to_restore_to> \ --name <cluster_name> \ --description <cluster_description> \ --environment <environment> \ --network-id <network_ID> \ --host zone-id=<availability_zone>,` `subnet-id=<subnet_ID>,` `assign-public-ip=<public_access_to_host>,` `type=<host_type> \ --router-resource-preset <router_host_class> \ --router-disk-size <storage_size_in_GB> \ --router-disk-type <disk_type> \ --coordinator-resource-preset <coordinator_host_class> \ --coordinator-disk-size <storage_size_in_GB> \ --coordinator-disk-type <disk_type> \ --infra-resource-preset <INFRA_host_class> \ --infra-disk-size <storage_size_in_GB> \ --infra-disk-type <disk_type> \ --backup-window-start <backup_start_time> \ --backup-retain-period-days <backup_retention_period> \ --security-group-ids <security_group_IDs> \ --deletion-protectionWhere:
-
--backup-id: Backup ID.You can get the backup ID with the list of backups.
-
--time: Point in time to restore the cluster to, inyyyy-mm-ddThh:mm:ssZformat. -
--name: Cluster name. -
--description: Cluster description. -
--environment: Cluster environment,PRODUCTIONorPRESTABLE. -
--network-id: ID of the network the cluster will be deployed in. -
--host: Host settings:-
zone-id: Availability zone. -
subnet-id: Subnet ID. -
assign-public-ip: Permission to connect to the host from the internet,trueorfalse. -
type: Host type. The possible values are:ROUTER: Router in a cluster with advanced sharding.COORDINATOR: Coordinator in a cluster with advanced sharding.INFRA:INFRAhost in a cluster with standard sharding.
-
-
--router-resource-preset: Class of router hosts. -
--router-disk-size: Storage size for router hosts, GB. -
--router-disk-type: Disk type for router hosts. -
--coordinator-resource-preset: Class of coordinator hosts. -
--coordinator-disk-size: Storage size for coordinator hosts, GB. -
--coordinator-disk-type: Disk type for coordinator hosts. -
--infra-resource-preset:INFRAhost class. -
--infra-disk-size:INFRAstorage size, GB. -
--infra-disk-type: Disk type forINFRAhosts. -
--backup-window-start: Daily backup start time (UTC) inHH:MM:SSformat. -
--backup-retain-period-days: Retention period of automatic cluster backups. Possible values: between7and60days. The default value is7. -
--security-group-ids: Security group IDs.Warning
For the router to be able to connect to your shard hosts, the Managed Service for Sharded PostgreSQL cluster and the shards and must be in the same security group that allows incoming and outgoing TCP connections to port
6432. -
--deletion-protection: Enables cluster deletion protection.
-
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Create a file named
body.jsonand paste the following code into it:{ "backupId": "<backup_ID>", "name": "<cluster_name>", "description": "<cluster_description>", "environment": "<environment>", "configSpec": { "spqrSpec": { "router": { "resources": { "resourcePresetId": "<router_host_class>", "diskSize": "<storage_size_in_bytes>", "diskTypeId": "<disk_type>" } }, "coordinator": { "resources": { "resourcePresetId": "<coordinator_host_class>", "diskSize": "<storage_size_in_bytes>", "diskTypeId": "<disk_type>" } }, "infra": { "resources": { "resourcePresetId": "<INFRA_host_class>", "diskSize": "<storage_size_in_bytes>", "diskTypeId": "<disk_type>" } }, "consolePassword": "<Sharded_PostgreSQL_console_password>", "logLevel": "<logging_level>" }, "backupWindowStart": { "hours": <hours>, "minutes": <minutes>, "seconds": <seconds>, "nanos": <nanoseconds> }, "backupRetainPeriodDays": "<number_of_days>" }, "hostSpecs": [ { "zoneId": "<availability_zone>", "subnetId": "<subnet_ID>", "assignPublicIp": <allow_public_access_to_host>, "type": "<host_type>", "shardName": "<shard_name>", "mdbPostgresql": { "clusterId": "<PostgreSQL_cluster_ID>" } }, { <similar_settings_for_host_2> }, { ... }, { <similar_settings_for_host_N> } ], "networkId": "<network_ID>", "folderId": "<folder_ID>", "securityGroupIds": [ "<security_group_1_ID>", "<security_group_2_ID>", ... "<security_group_N_ID>" ], "deletionProtection": <protect_cluster_from_deletion>, "time": "<time_point_to_restore_to>", "timeInclusive": <restore_after_specified_time> }Where:
-
backupId: Backup ID.You can get the backup ID with the list of backups.
-
name: Cluster name. -
description: Cluster description. -
environment: Cluster environment,PRODUCTIONorPRESTABLE. -
configSpec.spqrSpec.router.resources: Parameters of router host resources:resourcePresetId: Host class.diskSize: Disk size, in bytes.diskTypeId: Disk type.
-
configSpec.spqrSpec.coordinator.resources: Parameters of coordinator host resources:resourcePresetId: Host class.diskSize: Disk size, in bytes.diskTypeId: Disk type.
-
configSpec.spqrSpec.infra.resources:INFRAhost resource parameters:resourcePresetId: Host class.diskSize: Disk size, in bytes.diskTypeId: Disk type.
-
configSpec.spqrSpec.consolePassword: Sharded PostgreSQL console password. -
configSpec.spqrSpec.logLevel: Query logging level:DEBUG,INFO,WARNING,ERROR, orFATAL. -
configSpec.backupWindowStart: Backup window settings.Here, specify the backup start time. Allowed values:
hours: Between0and23hours.minutes: Between0and59minutes.seconds: Between0and59seconds.nanos: Between0and999999999nanoseconds.
-
configSpec.backupRetainPeriodDays: Retention period of automatic cluster backups. Possible values: between7and60days. The default value is7. -
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. -
type: Host type. The possible values are:ROUTER: Router in a cluster with advanced sharding.COORDINATOR: Coordinator in a cluster with advanced sharding.INFRA:INFRAhost in a cluster with standard sharding.
-
shardName: Shard name. -
mdbPostgresql.clusterId: Managed Service for PostgreSQL cluster ID.You can get the Managed Service for PostgreSQL cluster ID with the list of clusters in the folder.
-
-
networkId: ID of the network the cluster will be deployed in. -
folderId: Folder ID.You can get the folder ID with the list of folders in the cloud.
-
securityGroupIds: Security group IDs.Warning
For the router to be able to connect to your shard hosts, the Managed Service for Sharded PostgreSQL cluster and the shards and must be in the same security group that allows incoming and outgoing TCP connections to port
6432. -
deletionProtection: Cluster deletion protection,trueorfalse. -
time: Point in time to restore the cluster to, inyyyy-mm-ddThh:mm:ssZformat. -
timeInclusive: Restore the cluster after the specified time,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-spqr/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 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 that the repository contents reside in the
~/cloudapi/directory. -
Create a file named
body.jsonand paste the following code into it:{ "backup_id": "<backup_ID>", "name": "<cluster_name>", "description": "<cluster_description>", "environment": "<environment>", "config_spec": { "spqr_spec": { "router": { "resources": { "resource_preset_id": "<router_host_class>", "disk_size": <storage_size_in_bytes>, "disk_type_id": "<disk_type>" } }, "coordinator": { "resources": { "resource_preset_id": "<coordinator_host_class>", "disk_size": <storage_size_in_bytes>, "disk_type_id": "<disk_type>" } }, "infra": { "resources": { "resource_preset_id": "<INFRA_host_class>", "disk_size": <storage_size_in_bytes>, "disk_type_id": "<disk_type>" } }, "console_password": "<Sharded_PostgreSQL_console_password>", "log_level": "<logging_level>" }, "backup_window_start": { "hours": <hours>, "minutes": <minutes>, "seconds": <seconds>, "nanos": <nanoseconds> }, "backup_retain_period_days": <number_of_days> }, "host_specs": [ { "zone_id": "<availability_zone>", "subnet_id": "<subnet_ID>", "assign_public_ip": <allow_public_access_to_host>, "type": "<host_type>", "shard_name": "<shard_name>", "mdb_postgresql": { "cluster_id": "<PostgreSQL_cluster_ID>" } }, { <similar_settings_for_host_2> }, { ... }, { <similar_settings_for_host_N> } ], "network_id": "<network_ID>", "folder_id": "<folder_ID>", "security_group_ids": [ "<security_group_1_ID>", "<security_group_2_ID>", ... "<security_group_N_ID>" ], "deletion_protection": <protect_cluster_from_deletion>, "time": "<time_point_to_restore_to>", "time_inclusive": <restore_after_specified_time> }Where:
-
backup_id: Backup ID.You can get the backup ID with the list of backups.
-
name: Cluster name. -
description: Cluster description. -
environment: Cluster environment,PRODUCTIONorPRESTABLE. -
config_spec.spqr_spec.router.resources: Parameters of router host resources:resource_preset_id: Host class.disk_size: Disk size, in bytes.disk_type_id: Disk type.
-
config_spec.spqr_spec.coordinator.resources: Parameters of coordinator host resources:resource_preset_id: Host class.disk_size: Disk size, in bytes.disk_type_id: Disk type.
-
config_spec.spqr_spec.infra.resources:INFRAhost resource parameters:resource_preset_id: Host class.disk_size: Disk size, in bytes.disk_type_id: Disk type.
-
config_spec.spqr_spec.console_password: Sharded PostgreSQL console password. -
config_spec.spqr_spec.log_level: Query logging level:DEBUG,INFO,WARNING,ERROR, orFATAL. -
config_spec.backup_window_start: Backup window settings.Here, specify the backup start time. Allowed values:
hours: Between0and23hours.minutes: Between0and59minutes.seconds: Between0and59seconds.nanos: Between0and999999999nanoseconds.
-
config_spec.backup_retain_period_days: Retention period of automatic cluster backups. Possible values: between7and60days. -
host_specs: Cluster host settings as an array of elements, one per 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. -
type: Host type. The possible values are:ROUTER: Router in a cluster with advanced sharding.COORDINATOR: Coordinator in a cluster with advanced sharding.INFRA:INFRAhost in a cluster with standard sharding.
-
shard_name: Shard name. -
mdb_postgresql.cluster_id: Managed Service for PostgreSQL cluster ID.You can get the Managed Service for PostgreSQL cluster ID with the list of clusters in the folder.
-
-
network_id: ID of the network the cluster will be deployed in. -
folder_id: Folder ID.You can get the folder ID with the list of folders in the cloud.
-
security_group_ids: Security group IDs.Warning
For the router to be able to connect to your shard hosts, the Managed Service for Sharded PostgreSQL cluster and the shards and must be in the same security group that allows incoming and outgoing TCP connections to port
6432. -
deletion_protection: Cluster deletion protection,trueorfalse. -
time: Point in time to restore the cluster to, inyyyy-mm-ddThh:mm:ssZformat. -
time_inclusive: Restore the cluster after the specified time,trueorfalse.
-
-
Call the ClusterService.Restore 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/spqr/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.ClusterService.Restore \ < body.json -
Check the server response to make sure your request was successful.
Creating a backup
- Navigate to the folder dashboard
and select Yandex Managed Service for Sharded PostgreSQL. - Click the name of your cluster and select the
Backups tab. - Click Create backup in the top-right corner of the page.
- Confirm the creation of a backup.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI 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 options.
To create a cluster backup:
-
See the description of the CLI command for creating a cluster backup:
yc managed-sharded-postgresql cluster backup --help -
Create a cluster backup:
yc managed-sharded-postgresql cluster backup <cluster_name_or_ID>
-
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-spqr/v1/clusters/<cluster_ID>:backup' -
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 that the repository contents reside 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/spqr/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.ClusterService.Backup -
Check the server response to make sure your request was successful.
Getting a list of backups
To get a list of backups for a specific cluster:
- Navigate to the folder dashboard
and select Yandex Managed Service for Sharded PostgreSQL. - Click the name of your cluster and select the
Backups tab.
To get a list of backups for all Managed Service for Sharded PostgreSQL clusters in a folder:
- Navigate to the folder dashboard
and select Yandex Managed Service for Sharded PostgreSQL. - In the left-hand panel, select
Backups.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI 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 options.
To get a list of backups for a specific cluster:
-
See the description of the CLI command for getting a list of cluster backups:
yc managed-sharded-postgresql cluster list-backups --help -
Get a list of cluster backups:
yc managed-sharded-postgresql cluster list-backups <cluster_name_or_ID>
To get a list of backups for all Managed Service for Sharded PostgreSQL clusters in a folder:
-
See the description of the CLI command for getting a list of backups:
yc managed-sharded-postgresql backup list --help -
Get a list of backups:
yc managed-sharded-postgresql backup list
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
To get a list of backups for a specific cluster:
-
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-spqr/v1/clusters/<cluster_ID>/backups' -
Check the server response to make sure your request was successful.
-
-
To get a list of backups for all Managed Service for Sharded PostgreSQL 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-spqr/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 that the repository contents reside in the
~/cloudapi/directory. -
To get a list of backups for a specific cluster:
-
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/spqr/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.ClusterService.ListBackups -
Check the server response to make sure your request was successful.
-
-
To get a list of backups for all Managed Service for Sharded PostgreSQL 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/spqr/v1/backup_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "folder_id": "<folder_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.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 details
To get backup details for an existing cluster:
- Navigate to the folder dashboard
and select Yandex Managed Service for Sharded PostgreSQL. - Click the name of your cluster and select the
Backups tab.
To get backup details for a deleted cluster:
- Navigate to the folder dashboard
and select Yandex Managed Service for Sharded PostgreSQL. - In the left-hand panel, select
Backups.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI 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 options.
To get details for a specific backup:
-
See the description of the CLI command for getting backup details:
yc managed-sharded-postgresql backup get --help -
Get backup details:
yc managed-sharded-postgresql backup get <backup_ID>You can get the 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-spqr/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 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 that the repository contents reside 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/spqr/v1/backup_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "backup_id": "<backup_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.BackupService.GetYou can get the backup ID with the list of backups.
-
Check the server response to make sure your request was successful.
Setting the backup start time
In the management console, you can set the backup start time when creating or updating a cluster.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI 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 options.
To set the backup start time:
-
View the description of the CLI command for updating a cluster:
yc managed-sharded-postgresql cluster update --help -
Set the backup start time:
yc managed-sharded-postgresql cluster update <cluster_name_or_ID> \ --backup-window-start <backup_start_time>Where
--backup-window-startis the daily backup start time (UTC) inHH:MM:SSformat.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Create a file named
body.jsonand paste the following code into it:{ "updateMask": "configSpec.backupWindowStart", "configSpec": { "backupWindowStart": { "hours": <hours>, "minutes": <minutes>, "seconds": <seconds>, "nanos": <nanoseconds> } } }Where:
-
updateMask: Comma-separated string of settings to update.In this example, only the
configSpec.backupWindowStartsetting is provided.Warning
When you update a cluster, all parameters of the object you are modifying will take their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the
updateMaskparameter. -
configSpec.backupWindowStart: Backup window settings.Here, specify the backup start time. Allowed values:
hours: Between0and23hours.minutes: Between0and59minutes.seconds: Between0and59seconds.nanos: Between0and999999999nanoseconds.
-
-
Call the Cluster.Update method, e.g., via the following cURL
request:curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/v1/clusters/<cluster_ID>' \ --data "@body.json" -
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 that the repository contents reside in the
~/cloudapi/directory. -
Create a file named
body.jsonand paste the following code into it:{ "update_mask": { "paths": [ "config_spec.backup_window_start" ] }, "config_spec": { "backup_window_start": { "hours": <hours>, "minutes": <minutes>, "seconds": <seconds>, "nanos": <nanoseconds> } } }Where:
-
update_mask: List of settings to update as an array of strings (paths[]).Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }In this example, only the
config_spec.backup_window_startsetting is provided.Warning
When you update a cluster, all parameters of the object you are modifying will take their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the
update_maskparameter. -
config_spec.backup_window_start: Backup window settings.Here, specify the backup start time. Allowed values:
hours: Between0and23hours.minutes: Between0and59minutes.seconds: Between0and59seconds.nanos: Between0and999999999nanoseconds.
-
-
Call the ClusterService.Update 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/spqr/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.ClusterService.Update \ < body.json -
Check the server response to make sure your request was successful.
Setting a retention period for automatic backups
You can set the retention period for automatic backups when you create or update the cluster via the management console.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI 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 options.
To set a retention period for automatic backups:
-
View the description of the CLI command for updating a cluster:
yc managed-sharded-postgresql cluster update --help -
Set a retention period for automatic backups:
yc managed-sharded-postgresql cluster update <cluster_name_or_ID> \ --backup-retain-period-days <number_of_days>Where
--backup-retain-period-daysis the retention period of automatic cluster backups. Possible values: between7and60days. The default value is7.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Create a file named
body.jsonand paste the following code into it:{ "updateMask": "configSpec.backupRetainPeriodDays", "configSpec": { "backupRetainPeriodDays": "<number_of_days>" } }Where:
-
updateMask: Comma-separated string of settings to update.In this example, only the
configSpec.backupRetainPeriodDayssetting is provided.Warning
When you update a cluster, all parameters of the object you are modifying will take their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the
updateMaskparameter. -
backupRetainPeriodDays: Retention period of automatic cluster backups. Possible values: between7and60days. The default value is7.
-
-
Call the Cluster.Update method, e.g., via the following cURL
request:curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/v1/clusters/<cluster_ID>' \ --data "@body.json" -
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 that the repository contents reside in the
~/cloudapi/directory. -
Create a file named
body.jsonand paste the following code into it:{ "update_mask": { "paths": [ "config_spec.backup_retain_period_days" ] }, "config_spec": { "backup_retain_period_days": <number_of_days> } }Where:
-
update_mask: List of settings to update as an array of strings (paths[]).Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }In this example, only the
config_spec.backup_retain_period_dayssetting is provided.Warning
When you update a cluster, all parameters of the object you are modifying will take their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the
update_maskparameter. -
config_spec.backup_retain_period_days: Retention period of automatic cluster backups. Possible values: between7and60days. The default value is7.
-
-
Call the ClusterService.Update 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/spqr/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.ClusterService.Update \ < body.json -
Check the server response to make sure your request was successful.
Deleting a backup
You can only delete manual backups.
- Navigate to the folder dashboard
and select Yandex Managed Service for Sharded PostgreSQL. - Click the name of your cluster and select the
Backups tab. - Click
next to the backup you want to delete and select Delete backup. - Confirm deleting the backup.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI 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 options.
To delete a backup:
-
View a description of the CLI delete backup command:
yc managed-sharded-postgresql backup delete --help -
Delete the backup:
yc managed-sharded-postgresql backup delete <backup_ID>You can get the 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, e.g., via the following cURL
request:curl \ --request DELETE \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/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 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 that the repository contents reside in the
~/cloudapi/directory. -
Call the BackupService.Delete 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/spqr/v1/backup_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "backup_id": "<backup_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.BackupService.DeleteYou can get the backup ID with the list of backups.
-
Check the server response to make sure your request was successful.