Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for PostgreSQL
  • Getting started
    • All guides
      • Getting information on existing clusters
      • Creating a cluster
      • Updating cluster settings
      • Stopping and starting a cluster
      • Managing PostgreSQL hosts
      • Migrating hosts to a different availability zone
      • Managing replication slots
      • Managing backups
      • Managing disk space
      • Maintenance
      • Updating the PostgreSQL version
      • Deleting a cluster
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Restoring clusters from backups
  • Creating a backup
  • Getting a list of backups
  • Getting information about backups
  • Setting the backup start time
  • Setting a retention period for automatic backups
  • Deleting a backup
  1. Step-by-step guides
  2. Clusters
  3. Managing backups

Managing backups in Managed Service for PostgreSQL

Written by
Yandex Cloud
Updated at May 5, 2025
  • Restoring clusters from backups
  • Creating a backup
  • Getting a list of backups
  • Getting information about backups
  • Setting the backup start time
  • Setting a retention period for automatic backups
  • Deleting a backup

You can create backups and restore clusters from existing backups.

Managed Service for PostgreSQL also creates automatic daily backups. You can set the backup start time and retention period.

Restoring clusters from backupsRestoring clusters from backups

Point-in-Time Recovery (PITR) technology allows you to restore the cluster state to any point in time in the interval from the creation of the oldest full backup to the archiving of the most recent write ahead log (WAL). For more information, see Backups.

When you restore a cluster from a backup, you create a new cluster with the backup data. If the folder has insufficient resources to create such a cluster, you will not be able to restore from the backup. The average backup recovery speed is 10 MBps per database core.

When creating a new cluster, set all required parameters.

When restored to the current state, the new cluster will match the state of:

  • Existing cluster at the time of recovery.
  • Deleted cluster at the time of archiving the most recent WAL.

Warning

For backups created manually:

  • You cannot set any recovery time.
  • You can only restore a cluster to the state when the backup is completed.
Management console
CLI
Terraform
REST API
gRPC API

To restore an existing cluster from a backup:

  1. Go to the folder page and select Managed Service for PostgreSQL.

  2. Click the cluster name and open the Backups tab.

  3. Click for the backup you need, then click Restore cluster.

  4. Set up the new cluster. You can select a folder for the new cluster from the Folder list.

  5. 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 it was in when the backup was completed.

  6. Click Restore cluster.

To restore a previously deleted cluster from a backup:

  1. Go to the folder page and select Managed Service for PostgreSQL.

  2. Select the Backups tab.

  3. Find the backup you need using the backup creation time and cluster ID. The ID column contains IDs formatted as <cluster_ID>:<backup_IP>.

  4. Click for the backup you need, then click Restore cluster.

  5. Set up the new cluster. You can select a folder for the new cluster from the Folder list.

  6. 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 it was in when the backup was completed.

  7. Click Restore cluster.

Managed Service for PostgreSQL will launch the operation to create a cluster from the backup.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

By default, the cluster is restored to the same folder where the backup is stored. To restore the cluster to a different folder, specify its ID in the --folder-id parameter.

To restore a cluster from a backup:

  1. View a description of the CLI restore PostgreSQL cluster command:

    yc managed-postgresql cluster restore --help
    
  2. Getting a list of available PostgreSQL cluster backups:

    yc managed-postgresql backup list
    
    +--------------------------+---------------------+----------------------+---------------------+
    |              ID          |      CREATED AT     |  SOURCE CLUSTER ID   |      STARTED AT     |
    +--------------------------+---------------------+----------------------+---------------------+
    | c9qlk4v13uq7********:... | 2020-08-10 12:00:00 | c9qlk4v13uq7******** | 2020-08-10 11:55:17 |
    | ...                                                                                         |
    +--------------------------+---------------------+----------------------+---------------------+
    

    The backup completion time is shown in the CREATED AT column of the list of available backups, in yyyy-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.

  3. Request creating a cluster from a backup:

    yc managed-postgresql 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 PostgreSQL cluster to, in yyyy-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 to add if public access to the host is required (true or false).

    • --resource-preset: Host class.

    • --disk-size: Storage size in GB.

    • --disk-type: Disk type:

      • network-hdd
      • network-ssd
      • local-ssd
      • network-ssd-nonreplicated * network-ssd-io-m3.

Use Terraform to restore:

  • Existing cluster from a backup.
  • Cluster created and deleted via the management console, CLI, or API.

Note

The cluster will be restored to the folder whose ID is specified in the folder_id parameter of provider settings.

To restore a cluster, you will need the backup ID. Get a list of available PostgreSQL cluster backups using the CLI:

yc managed-postgresql backup list
+--------------------------+---------------------+----------------------+---------------------+
|            ID            |      CREATED AT     |  SOURCE CLUSTER ID   |      STARTED AT     |
+--------------------------+---------------------+----------------------+---------------------+
| c9qlk4v13uq7********:... | 2020-08-10 12:00:00 | c9qlk4v13uq7******** | 2020-08-10 11:55:17 |
| ...                                                                                         |
+--------------------------+---------------------+----------------------+---------------------+

Time limits

A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:

  • Creating a cluster, including restoring from a backup: 30 minutes.
  • Editing a cluster: 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_postgresql_cluster" "<cluster_name>" {
  ...
  timeouts {
    create = "1h30m" # 1 hour 30 minutes
    update = "2h"    # 2 hours
    delete = "30m"   # 30 minutes
  }
}

To restore an existing cluster from a backup:

  1. Create a Terraform configuration file for the new cluster.

    Do not use the database (yandex_mdb_postgresql_database) and user (yandex_mdb_postgresql_user) resources: these will be restored from the backup.

  2. Add the restore section to the configuration file:

    resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
      ...
      restore {
        backup_id = "<backup_ID>"
        time      = "<time>"
      }
    }
    

    Where:

    • backup_id: Backup ID.
    • time: Point in time to restore the PostgreSQL cluster to, starting from the selected backup's creation time. Format: yyyy-mm-ddThh:mm:ss.

    Note

    If you omit the time parameter, the cluster will be restored to the backup completion time.

  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If 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.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. 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.

To restore a previously deleted cluster from a backup:

  1. Create a Terraform configuration file for the new cluster.

    Do not use the database (yandex_mdb_postgresql_database) and user (yandex_mdb_postgresql_user) resources: these will be restored from the backup.

  2. In this configuration file, add a restore section with the name of the backup to restore the cluster from:

    resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
      ...
      restore {
          backup_id = "<backup_ID>"
      }
    }
    

    Where backup-id is the ID of the deleted cluster’s backup.

  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If 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.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

Terraform will create the new cluster. The databases and users are deployed from the backup.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. 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 PostgreSQL cluster to, in yyyy-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: PostgreSQL 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 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.
  3. Use the Cluster.Restore method and send the following 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-postgresql/v1/clusters:restore' \
      --data "@body.json"
    
  4. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. 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.

  3. 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": "<PostgreSQL_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 together with a list of backups.

    • time: Time point to restore the PostgreSQL cluster to, in yyyy-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: PostgreSQL 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.
  4. 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/postgresql/v1/cluster_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d @ \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.postgresql.v1.ClusterService.Restore \
      < body.json
    
  5. View the server response to make sure the request was successful.

Creating a backupCreating a backup

Management console
CLI
REST API
gRPC API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Click the cluster name and open the Backups tab.
  3. Click Create backup.

The service will start creating a backup without an additional confirmation.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To create a cluster backup:

  1. View a description of the CLI create PostgreSQL backup command:

    yc managed-postgresql cluster backup --help
    
  2. Request the creation of a backup specifying the cluster name or ID:

    yc managed-postgresql cluster backup my-pg-cluster
    

    The cluster name and ID can be retrieved with the list of clusters.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Cluster.Backup method and send the following 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-postgresql/v1/clusters/<cluster_ID>:backup'
    

    You can get the cluster ID with a list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. 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.

  3. 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/postgresql/v1/cluster_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "cluster_id": "<cluster_ID>"
          }' \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.postgresql.v1.ClusterService.Backup
    

    You can get the cluster ID with a list of clusters in the folder.

  4. View the server response to make sure the request was successful.

Warning

While you are creating your backup, the cluster performance might degrade.

Getting a list of backupsGetting a list of backups

Management console
CLI
REST API
gRPC API

To get a list of cluster backups:

  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Click the cluster name and open the Backups tab.

To get a list of all backups in a folder:

  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Select the Backups tab.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To get a list of PostgreSQL cluster backups available in the default folder, run the command:

yc managed-postgresql backup list

+--------------------------+---------------------+----------------------+---------------------+
|            ID            |      CREATED AT     |  SOURCE CLUSTER ID   |      STARTED AT     |
+--------------------------+---------------------+----------------------+---------------------+
| c9qlk4v13uq7********:... | 2020-08-10 12:00:00 | c9qlk4v13uq7******** | 2020-08-10 11:55:17 |
| c9qpm90p3pcg********:... | 2020-08-09 22:01:04 | c9qpm90p3pcg******** | 2020-08-09 21:30:00 |
+--------------------------+---------------------+----------------------+---------------------+
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. To get a list of cluster backups:

    1. Use the Cluster.ListBackups method and send the following request, e.g., via cURL:

      curl \
         --request GET \
         --header "Authorization: Bearer $IAM_TOKEN" \
         --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/<cluster_ID>/backups'
      

      You can get the cluster ID with a list of clusters in the folder.

    2. View the server response to make sure the request was successful.

  3. To get a list of backups for all the clusters in a folder:

    1. Use the Backup.List method and send the following request, e.g., via cURL:

      curl \
         --request GET \
         --header "Authorization: Bearer $IAM_TOKEN" \
         --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/backups' \
         --url-query folderId=<folder_ID>
      

      You can request the folder ID with the list of folders in the cloud.

    2. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. 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.

  3. To get a list of cluster backups:

    1. 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/postgresql/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>"
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.postgresql.v1.ClusterService.ListBackups
      

      You can get the cluster ID with a list of clusters in the folder.

    2. View the server response to make sure the request was successful.

  4. To get a list of backups for all the clusters in a folder:

    1. 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/postgresql/v1/backup_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "folder_id": "<folder_ID>"
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.postgresql.v1.BackupService.List
      

      You can request the folder ID with the list of folders in the cloud.

    2. View the server response to make sure the request was successful.

Getting information about backupsGetting information about backups

Management console
CLI
REST API
gRPC API

To get information about the backup of an existing cluster:

  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Click the cluster name and open the Backups tab.

To get information about the backup of a previously deleted cluster:

  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Select the Backups tab.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To get information about a PostgreSQL cluster backup, run the command:

yc managed-postgresql backup get <backup_ID>

You can retrieve the backup ID with a list of backups.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Backup.Get method and send the following request, e.g., via cURL:

    curl \
       --request GET \
       --header "Authorization: Bearer $IAM_TOKEN" \
       --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/backups/<backup_ID>'
    

    You can get the backup ID together with a list of backups.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. 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.

  3. 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/postgresql/v1/backup_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "backup_id": "<backup_ID>"
          }' \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.postgresql.v1.BackupService.Get
    

    You can get the backup ID together with a list of backups.

  4. View the server response to make sure the request was successful.

Setting the backup start timeSetting the backup start time

Management console
CLI
Terraform
REST API
gRPC API

In the management console, you can set the backup start time when creating or updating a cluster.

To set the backup start time, use the --backup-window-start flag. Time is given in HH:MM:SS format.

yc managed-postgresql cluster create \
   --cluster-name <cluster_name> \
   --environment <environment> \
   --network-name <network_name> \
   --host zone-id=<availability_zone>,subnet-id=<subnet_ID> \
   --resource-preset <host_class> \
   --user name=<username>,password=<user_password> \
   --database name=<DB_name>,owner=<database_owner_name> \
   --disk-size <storage_size_in_GB>
   --backup-window-start 10:00:00

Where environment is the environment: prestable or production.

To change the backup start time in an existing cluster, use the update command:

yc managed-postgresql cluster update \
   --cluster-name <cluster_name> \
   --backup-window-start 11:25:00
  1. 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 PostgreSQL cluster configuration fields, see the Terraform provider documentation.

  2. Add a backup_window_start block in the config section to the Managed Service for PostgreSQL cluster description:

    resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
      ...
      config {
        ...
        backup_window_start {
          hours   = <hour>
          minutes = <minute>
        }
        ...
      }
      ...
    

    Where:

    • hours: Backup start hour (UTC).
    • minutes: Backup start minute (UTC).
  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If 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.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

    Time limits

    A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:

    • Creating a cluster, including restoring from a backup: 30 minutes.
    • Editing a cluster: 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_postgresql_cluster" "<cluster_name>" {
      ...
      timeouts {
        create = "1h30m" # 1 hour 30 minutes
        update = "2h"    # 2 hours
        delete = "30m"   # 30 minutes
      }
    }
    
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Cluster.Update method and send the following 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-postgresql/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: Between 0 and 23 hours.
      • minutes: Between 0 and 59 minutes.
      • seconds: Between 0 and 59 seconds.
      • nanos: Between 0 and 999999999 nanoseconds.

    You can get the cluster ID with a list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. 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.

  3. 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_mask parameter as an array of paths[] 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/postgresql/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.postgresql.v1.ClusterService.Update
    

    Where:

    • update_mask: List of parameters to update as an array of paths[] strings.

      Only one parameter is provided in this case.

    • config_spec.backup_window_start: Backup window settings.

      In this parameter, specify the backup start time. Possible values:

      • hours: Between 0 and 23 hours.
      • minutes: Between 0 and 59 minutes.
      • seconds: Between 0 and 59 seconds.
      • nanos: Between 0 and 999999999 nanoseconds.

    You can get the cluster ID with a list of clusters in the folder.

  4. View the server response to make sure the request was successful.

Setting a retention period for automatic backupsSetting a retention period for automatic backups

Management console
CLI
Terraform
REST API
gRPC API

In the management console, you can set the retention period for automatic backups when creating or modifying a cluster.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder 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-postgresql 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.

  1. 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 PostgreSQL cluster configuration fields, see the Terraform provider documentation.

  2. Add a backup_retain_period_days block in the config section to the Managed Service for PostgreSQL cluster description:

      resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
        ...
        config {
          ...
          backup_retain_period_days = <retention_period_in_days>
          }
          ...
        }
        ...
    

    Where backup_retain_period_days is the automatic backup retention period.

    The possible values range from 7 to 60. The default value is 7.

  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If 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.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

    Time limits

    A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:

    • Creating a cluster, including restoring from a backup: 30 minutes.
    • Editing a cluster: 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_postgresql_cluster" "<cluster_name>" {
      ...
      timeouts {
        create = "1h30m" # 1 hour 30 minutes
        update = "2h"    # 2 hours
        delete = "30m"   # 30 minutes
      }
    }
    
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Cluster.Update method and send the following 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-postgresql/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.

      Only one parameter is provided in this case.

    • configSpec.backupRetainPeriodDays: Automatic backup retention period.

      The values range from 7 to 60. The default value is 7.

    You can get the cluster ID with a list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. 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.

  3. 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_mask parameter as an array of paths[] 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/postgresql/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": <retention_period_in_days>
            }
        }' \
    mdb.api.cloud.yandex.net:443 \
    yandex.cloud.mdb.postgresql.v1.ClusterService.Update
    

    Where:

    • update_mask: List of parameters to update as an array of paths[] strings.

      Only one parameter is provided in this case.

    • config_spec.backup_retain_period_days: Automatic backup retention period.

      The values range from 7 to 60. The default value is 7.

    You can get the cluster ID with a list of clusters in the folder.

  4. View the server response to make sure the request was successful.

Deleting a backupDeleting a backup

You can only delete backups that were created manually.

Management console
CLI
REST API
gRPC API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Select the Managed Service for PostgreSQL cluster whose backup you want to delete.
  3. In the left-hand panel, select Backups.
  4. Click to the right of the backup you want to delete.
  5. Select Delete backup.
  6. Confirm deletion and click Delete.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To delete a backup:

  1. View a description of the CLI command to delete a PostgreSQL cluster backup:

    yc managed-postgresql backup delete --help
    
  2. Request the deletion of a backup by specifying its ID:

    yc managed-postgresql backup delete <backup_ID>
    

You can retrieve the backup ID with a list of backups.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Backup.Delete method and send the following request, e.g., via cURL:

    curl \
      --request DELETE \
      --header "Authorization: Bearer $IAM_TOKEN" \
      --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/backups/<backup_ID>'
    

    You can get the backup ID together with a list of backups.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. 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.

  3. Use the BackupService.Delete 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/postgresql/v1/backup_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "backup_id": "<backup_ID>"
          }' \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.postgresql.v1.BackupService.Delete
    

    You can get the backup ID together with a list of backups.

  4. View the server response to make sure the request was successful.

Was the article helpful?

Previous
Managing replication slots
Next
Managing disk space
© 2025 Direct Cursus Technology L.L.C.