[Yandex Cloud documentation](../../index.md) > [Yandex MPP Analytics for PostgreSQL](../index.md) > [Step-by-step guides](index.md) > Clusters > Managing backups

# Managing backups in Yandex MPP Analytics for PostgreSQL

You can view your existing [backups](../concepts/backup.md) and restore clusters from them.

## Getting a list of backups {#list-backups}

{% list tabs group=instructions %}

- Management console {#console}

    To get a list of cluster backups:
    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. Click the cluster name and open the ![image](../../_assets/console-icons/archive.svg) **Backups** tab.

    To get a list of all backups in your folder:
    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. In the left-hand panel, select ![image](../../_assets/console-icons/archive.svg) **Backups**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To get a list of Yandex MPP Analytics for PostgreSQL cluster backups, run this command:

    ```bash
    yc managed-greenplum cluster list-backups <cluster_name_or_ID>
    ```

    You can get the cluster ID and name with the [list of clusters in the folder](cluster-list.md#list-clusters).

    Result:

    ```text
    +--------------------------+---------------------+----------------------+---------------------+
    |            ID            |     CREATED AT      |  SOURCE CLUSTER ID   |     STARTED AT      |
    +--------------------------+---------------------+----------------------+---------------------+
    | c9qgo11pud7k********:... | 2020-08-10 12:00:00 | c9qgo11pud7k******** | 2020-08-10 11:55:17 |
    | ...                                                                                         |
    +--------------------------+---------------------+----------------------+---------------------+
    ```

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. To get a list of cluster backups:

        1. Call the [Cluster.ListBackups](../api-ref/Cluster/listBackups.md) method, e.g., via the following [cURL](https://curl.se/) request:

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

            You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

        1. Check the [server response](../api-ref/Cluster/listBackups.md#yandex.cloud.mdb.greenplum.v1.ListClusterBackupsResponse) to make sure your request was successful.

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

        1. Call the [Backup.List](../api-ref/Backup/list.md) method, e.g., via the following [cURL](https://curl.se/) request:

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

            
            You can get the folder ID with the [list of folders in the cloud](../../resource-manager/operations/folder/get-id.md).


        1. Check the [server response](../api-ref/Backup/list.md#yandex.cloud.mdb.greenplum.v1.ListBackupsResponse) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. To get a list of cluster backups:

        1. Call the [ClusterService.ListBackups](../api-ref/grpc/Cluster/listBackups.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

            ```bash
            grpcurl \
                -format json \
                -import-path ~/cloudapi/ \
                -import-path ~/cloudapi/third_party/googleapis/ \
                -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/cluster_service.proto \
                -rpc-header "Authorization: Bearer $IAM_TOKEN" \
                -d '{
                      "cluster_id": "<cluster_ID>"
                    }' \
                mdb.api.cloud.yandex.net:443 \
                yandex.cloud.mdb.greenplum.v1.ClusterService.ListBackups
            ```

            You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

        1. Check the [server response](../api-ref/grpc/Cluster/listBackups.md#yandex.cloud.mdb.greenplum.v1.ListClusterBackupsResponse) to make sure your request was successful.

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

        1. Call the [BackupService.List](../api-ref/grpc/Backup/list.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

            ```bash
            grpcurl \
                -format json \
                -import-path ~/cloudapi/ \
                -import-path ~/cloudapi/third_party/googleapis/ \
                -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/backup_service.proto \
                -rpc-header "Authorization: Bearer $IAM_TOKEN" \
                -d '{
                      "folder_id": "<folder_ID>"
                    }' \
                mdb.api.cloud.yandex.net:443 \
                yandex.cloud.mdb.greenplum.v1.BackupService.List
            ```

            
            You can get the folder ID with the [list of folders in the cloud](../../resource-manager/operations/folder/get-id.md).


        1. Check the [server response](../api-ref/grpc/Backup/list.md#yandex.cloud.mdb.greenplum.v1.ListBackupsResponse) to make sure your request was successful.

{% endlist %}

## Getting backup information {#get-backup}

{% list tabs group=instructions %}

- Management console {#console}

    To get backup details for an existing cluster:
    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. Click the cluster name and open the ![image](../../_assets/console-icons/archive.svg) **Backups** tab.

    To get backup details for a previously deleted cluster:
    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. In the left-hand panel, select ![image](../../_assets/console-icons/archive.svg) **Backups**.

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Call the [Backup.Get](../api-ref/Backup/get.md) method, e.g., via the following [cURL](https://curl.se/) request:

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

        You can get the backup ID with the [list of backups](#list-backups).

    1. Check the [server response](../api-ref/Backup/get.md#yandex.cloud.mdb.greenplum.v1.Backup) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [BackupService.Get](../api-ref/grpc/Backup/get.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        ```bash
        grpcurl \
            -format json \
            -import-path ~/cloudapi/ \
            -import-path ~/cloudapi/third_party/googleapis/ \
            -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/backup_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d '{
                  "backup_id": "<backup_ID>"
                }' \
            mdb.api.cloud.yandex.net:443 \
            yandex.cloud.mdb.greenplum.v1.BackupService.Get
        ```

        You can get the backup ID with the [list of backups](#list-backups).

    1. View the [server response](../api-ref/grpc/Backup/get.md#yandex.cloud.mdb.greenplum.v1.Backup) to make sure your request was successful.

{% endlist %}

## Creating a backup {#create-backup}

{% list tabs group=instructions %}

- Management console {#console}

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. Click the name of your cluster and select the ![image](../../_assets/console-icons/archive.svg) **Backups** tab.
    1. Click ![image](../../_assets/console-icons/plus.svg) **Create backup**.

    This will initiate creating a backup without any additional confirmation.

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Call the [Cluster.Backup](../api-ref/Cluster/backup.md) method, e.g., via the following [cURL](https://curl.se/) request:

        ```bash
        curl \
            --request POST \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>:backup'
        ```

        You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/Cluster/backup.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [ClusterService.Backup](../api-ref/grpc/Cluster/backup.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        ```bash
        grpcurl \
            -format json \
            -import-path ~/cloudapi/ \
            -import-path ~/cloudapi/third_party/googleapis/ \
            -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/cluster_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d '{
                  "cluster_id": "<cluster_ID>"
                }' \
            mdb.api.cloud.yandex.net:443 \
            yandex.cloud.mdb.greenplum.v1.ClusterService.Backup
        ```

        You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. View the [server response](../api-ref/grpc/Cluster/backup.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

While you are creating a backup, the cluster performance may degrade.

## Restoring a cluster from a backup {#restore}


{% note warning %}

For clusters running an unsupported DBMS version, restoring from backups is not available.

{% endnote %}


Before you begin, [assign](../../iam/operations/roles/grant.md) your Yandex Cloud account the [managed-greenplum.restorer](../../iam/roles-reference.md#managed-greenplum-restorer) role or higher for the backup folder and the new cluster folder.


{% list tabs group=instructions %}

- Management console {#console}

    To restore an existing cluster from a backup:

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. Click the cluster name and open the ![image](../../_assets/console-icons/archive.svg) **Backups** tab.
    1. Click ![image](../../_assets/console-icons/ellipsis.svg) for your backup and click **Restore cluster**.
    1. Configure the new cluster. You can select a folder for the new cluster from the **Folder** list.
    1. In the **Date and time of recovery (UTC)** setting, specify the time point to which you want to revert the cluster's state. You can enter a value manually or select one from the drop-down calendar. The system will select the restore point closest to that time.

       If you do not edit this setting, the cluster's state will be restored from the backup. No restore points will be used.

    
    1. In the **Service account** field, select the service account or create a new one. User applications will use this account to manage the cluster.
    

    1. If you want to restore only certain databases or tables, list them in the **Databases and tables for recovery** field. If you leave the field blank, the whole cluster will be restored.
    1. In the **Host count** setting, specify the number of segment hosts.
    1. In the **Segments per host** setting, specify the number of [segments](../concepts/index.md) per host.

        The segment host class and the number of segments per host [affect](../concepts/instance-types.md#select-class-segment-hosts) the maximum amount of memory allocated to each Yandex MPP Analytics for PostgreSQL server process. If you select a host class with small RAM and specify a large number of segments, an [error](../qa/cluster-hosts.md#memory-limit) may occur.

    
    1. Optionally, select groups of [dedicated hosts](../../compute/concepts/dedicated-host.md) to place master hosts or segment hosts on dedicated hosts. You can assign groups to one of the two Yandex MPP Analytics for PostgreSQL host types or to both of them at once.

        You must first [create](../../compute/operations/dedicated-host/create-host-group.md) a group of dedicated hosts in Yandex Compute Cloud.

        You cannot edit this setting after you create a cluster. 
        
        If using dedicated hosts, the cluster cost is a sum of the charge for [computing resources Yandex Compute Cloud](../../compute/pricing.md#prices-dedicated-host) and the [markup Yandex MPP Analytics for PostgreSQL](../pricing/index.md#dedicated-hosts).


    1. If there were external data sources created in the cluster, select **Data sources (PXF)** to restore them. You cannot select individual sources.

    1. If there were user authentication rules created in the cluster, select **User authentication rules** to restore them. You cannot select individual rules.

    1. Click **Create**.

    To restore a previously deleted cluster from a backup:
    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. In the left-hand panel, select ![image](../../_assets/console-icons/archive.svg) **Backups**.
    1. Find your backup using the backup creation time and cluster ID. The **ID** column contains IDs in `<cluster_ID>:<backup_ID>` format.
    1. Click ![image](../../_assets/console-icons/ellipsis.svg) for the backup you need and then click **Restore cluster**.
    1. Configure the new cluster. You can select a folder for the new cluster from the **Folder** list.
    1. In the **Date and time of recovery (UTC)** setting, specify the time point to which you want to revert the cluster's state. You can enter a value manually or select one from the drop-down calendar. The system will select the restore point closest to that time.

       If you do not edit this setting, the cluster's state will be restored from the backup. No restore points will be used.

    
    1. In the **Service account** field, select the service account or create a new one. User applications will use this account to manage the cluster.
    
    
    1. If you want to restore only certain databases or tables, list them in the **Databases and tables for recovery** field. If you leave the field blank, the whole cluster will be restored.
    1. In the **Host count** setting, specify the number of segment hosts.
    1. In the **Segments per host** setting, specify the number of [segments](../concepts/index.md) per host.

        The segment host class and the number of segments per host [affect](../concepts/instance-types.md#select-class-segment-hosts) the maximum amount of memory allocated to each Yandex MPP Analytics for PostgreSQL server process. If you select a host class with small RAM and specify a large number of segments, an [error](../qa/cluster-hosts.md#memory-limit) may occur.

    
    1. Optionally, select groups of [dedicated hosts](../../compute/concepts/dedicated-host.md) to place master hosts or segment hosts on dedicated hosts. You can assign groups to one of the two Yandex MPP Analytics for PostgreSQL host types or to both of them at once.

        You must first [create](../../compute/operations/dedicated-host/create-host-group.md) a group of dedicated hosts in Yandex Compute Cloud.

        You cannot edit this setting after you create a cluster. 
        
        If using dedicated hosts, the cluster cost is a sum of the charge for [computing resources Yandex Compute Cloud](../../compute/pricing.md#prices-dedicated-host) and the [markup Yandex MPP Analytics for PostgreSQL](../pricing/index.md#dedicated-hosts).


    1. If there were external data sources created in the cluster, select **Data sources (PXF)** to restore them. You cannot select individual sources.

    1. If there were user authentication rules created in the cluster, select **User authentication rules** to restore them. You cannot select individual rules.

    1. Click **Create**.

    Yandex MPP Analytics for PostgreSQL will start creating the cluster from the backup.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To restore a cluster from a backup:

    1. View the description of the CLI command for restoring a Yandex MPP Analytics for PostgreSQL cluster:

        ```bash
        yc managed-greenplum cluster restore --help
        ```

    1. Make the following request to create a cluster from a backup:

        
        ```bash
        yc managed-greenplum cluster restore \
           --backup-id=<backup_ID> \
           --time=<time_point> \
           --name=<cluster_name> \
           --environment=<environment> \
           --network-name=default \
           --master-resource-preset=<host_class> \
           --master-disk-size=<storage_size_in_GB> \
           --master-disk-type=<disk_type> \
           --segment-resource-preset=<host_class> \
           --segment-disk-size=<storage_size_in_GB> \
           --segment-disk-type=<disk_type> \
           --segment-host-count <number_of_segment_hosts> \
           --segment-in-host <number_of_segments_per_host> \
           --restore-only=<list_of_DBs_and_tables_to_restore> \
           --zone-id=<availability_zone> \
           --subnet-id=<subnet_ID> \
           --assign-public-ip=<enable_public_access_to_cluster> \
           --master-host-group-ids=<IDs_of_dedicated_host_groups_for_master_hosts> \
           --segment-host-group-ids=<IDs_of_dedicated_host_groups_for_segment_hosts> \
           --service-account <service_account_ID>
        ```


        Where:

        * `--backup-id`: [Backup](../concepts/backup.md) ID.
        * `--time`: Time point to restore the Yandex MPP Analytics for PostgreSQL cluster to, in `yyyy-mm-ddThh:mm:ssZ` format. By default, the cluster will be restored to the backup state.
        * `--name`: Cluster name.
        * `--environment`: Environment:

            * `PRESTABLE`: For testing purposes. The prestable environment is similar to the production environment and likewise covered by an SLA, but it is the first to get new features, improvements, and bug fixes. In the prestable environment, you can test new versions for compatibility with your application.
            * `PRODUCTION`: For stable versions of your applications.

        * `--network-name`: [Network name](../../vpc/concepts/network.md#network).
        * `--master-resource-preset`: [Master host class](../concepts/instance-types.md#available-flavors).
        * `--master-disk-size`: Size of master host storage in GB.
        * `--master-disk-type`: [Disk type](../concepts/storage.md) for master hosts.
        * `--segment-resource-preset`: [Segment host class](../concepts/instance-types.md#available-flavors).

            The segment host class and the number of segments per host [affect](../concepts/instance-types.md#select-class-segment-hosts) the maximum amount of memory allocated to each Yandex MPP Analytics for PostgreSQL server process. If you select a host class with small RAM and specify a large number of segments, an [error](../qa/cluster-hosts.md#memory-limit) may occur.

        * `--segment-disk-size`: Size of segment host storage in GB.
        * `--segment-disk-type`: [Disk type](../concepts/storage.md) for segment hosts.
        * `--segment-host-count`: Number of segment hosts.
        * `--segment-in-host`: Number of [segments](../concepts/index.md) per host.
        * `--restore-only`: Comma-separated list of DBs and tables to restore from the backup. This is an optional setting. Supported formats: `<DB>/<schema>/<table>`, `<DB>/<table>`, and `<DB>`. You may use the `*` wildcard symbol as well. If you omit this setting, the whole cluster will be restored.
        * `--zone-id`: [Availability zone](../../overview/concepts/geo-scope.md).

        
        * `--master-host-group-ids` and `--segment-host-group-ids`: IDs of [dedicated host](../../compute/concepts/dedicated-host.md) groups for master and segment hosts. This is an optional setting.

            You must first [create](../../compute/operations/dedicated-host/create-host-group.md) a group of dedicated hosts in Yandex Compute Cloud.

            You cannot edit this setting after you create a cluster. 
            
            If using dedicated hosts, the cluster cost is a sum of the charge for [computing resources Yandex Compute Cloud](../../compute/pricing.md#prices-dedicated-host) and the [markup Yandex MPP Analytics for PostgreSQL](../pricing/index.md#dedicated-hosts).

        * `--subnet-id`: [Subnet ID](../../vpc/concepts/network.md#subnet). Specify it if the selected availability zone has two or more subnets.
        * `--assign-public-ip`: Flag you set if the cluster needs access from the internet.
        * `--service-account`: Service account ID.


- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Create a file named `body.json` and paste the following code into it:

        
        ```json
        {
          "backupId": "<backup_ID>",
          "time": "<time>",
          "folderId": "<folder_ID>",
          "name": "<cluster_name>",
          "environment": "<environment>",
          "networkId": "<network_ID>",
          "config": {
            "zoneId": "<availability_zone>",
            "subnetId": "<subnet_ID>",
            "assignPublicIp": "<enable_public_access_to_cluster_hosts>"
          },
          "masterResources": {
            "resourcePresetId": "<host_class>",
            "diskSize": "<storage_size_in_bytes>",
            "diskTypeId": "<disk_type>"
          },
          "segmentResources": {
            "resourcePresetId": "<host_class>",
            "diskSize": "<storage_size_in_bytes>",
            "diskTypeId": "<disk_type>"
          },
          "segmentHostCount": "<number_of_segment_hosts>",
          "segmentInHost": "<number_of_segments_per_host>",
          "restoreOnly": [
            "<DB_and_table_1>",
            "<DB_and_table_2>",
            ...
            "<DB_and_table_N>"
          ],
          "masterHostGroupIds": [
            "string"
          ],
          "segmentHostGroupIds": [
            "string"
          ],
          "serviceAccountId": "<service_account_ID>",
          "logging": {
            "enabled": "<enable_transferring_logs>",
            "commandCenterEnabled": "<transfer_Yandex_Command_Center_logs>",
            "greenplumEnabled": "<transfer_DBMS_logs>",
            "poolerEnabled": "<transfer_connection_pooler_logs>",
            "folderId": "<folder_ID>"
          }
        }
        ```


        Where:

        * `backupId`: [Backup](../concepts/backup.md) ID. You can get it with the [list of backups](#list-backups).
        * `time`: Time point to restore the Yandex MPP Analytics for PostgreSQL cluster to, in `yyyy-mm-ddThh:mm:ssZ` format. By default, the cluster will be restored to the backup state.
        * `folderId`: ID of the folder you want to restore the cluster to. You can request the ID with the [list of folders in the cloud](../../resource-manager/operations/folder/get-id.md). By default, the cluster is restored to the same folder the backup is in.
        * `name`: Name of the new cluster.
        * `environment`: Environment:

            * `PRESTABLE`: For testing purposes. The prestable environment is similar to the production environment and likewise covered by an SLA, but it is the first to get new features, improvements, and bug fixes. In the prestable environment, you can test new versions for compatibility with your application.
            * `PRODUCTION`: For stable versions of your applications.

        * `networkId`: [Network](../../vpc/concepts/network.md#network) ID.
        * `config`: Cluster settings:

            * `zoneId`: [Availability zone](../../overview/concepts/geo-scope.md).
            * `subnetId`: [Subnet](../../vpc/concepts/network.md#subnet) ID.
            * `assignPublicIp`: Public access to cluster hosts, `true` or `false`.

        * `masterResources`, `segmentResources`: Master and segment host configuration in the cluster:

            * `resourcePresetId`: [Host class](../concepts/instance-types.md).
            * `diskSize`: Disk size, in bytes.
            * `diskTypeId`: [Disk type](../concepts/storage.md).

        * `segmentHostCount`: Number of segment hosts, from `2` to `32`.
        * `segmentInHost`: [Number of segments per host](../concepts/index.md). The maximum value of this setting depends on the host class.

            The segment host class and the number of segments per host [affect](../concepts/instance-types.md#select-class-segment-hosts) the maximum amount of memory allocated to each Yandex MPP Analytics for PostgreSQL server process. If you select a host class with small RAM and specify a large number of segments, an [error](../qa/cluster-hosts.md#memory-limit) may occur.

        * `restoreOnly`: List of DBs and tables to restore from the backup. This is an optional setting. Supported formats: `<DB>/<schema>/<table>`, `<DB>/<table>`, and `<DB>`. You may use the `*` wildcard symbol as well. If you omit this setting, the whole cluster will be restored.

        
        * `masterHostGroupIds` and `segmentHostGroupIds`: IDs of [dedicated host](../../compute/concepts/dedicated-host.md) groups for master and segment hosts. This is an optional setting.

            You must first [create](../../compute/operations/dedicated-host/create-host-group.md) a group of dedicated hosts in Yandex Compute Cloud.

            You cannot edit this setting after you create a cluster. 
            
            If using dedicated hosts, the cluster cost is a sum of the charge for [computing resources Yandex Compute Cloud](../../compute/pricing.md#prices-dedicated-host) and the [markup Yandex MPP Analytics for PostgreSQL](../pricing/index.md#dedicated-hosts).

        * `serviceAccountId`: Service account ID.
        * `logging`: Settings for [transferring logs to Yandex Cloud Logging](mgp-to-cloud-logging.md):

            * `enabled`: Manages log transfer, `true` or `false`. To enable parameters responsible for transferring specific logs, provide the `true` value.
            * `commandCenterEnabled`: Transferring [Command Center](../concepts/command-center.md) logs, `true` or `false`.
            * `greenplumEnabled`: Transferring DBMS logs, `true` or `false`.
            * `poolerEnabled`: Transferring [connection pooler](../concepts/pooling.md) logs, `true` or `false`.
            * `folderId`: Specify the ID of the folder whose log group you want to use.
            * `logGroupId`: ID of the log group to write logs to.

                Specify either `folderId` or `logGroupId`.


    1. Call the [Cluster.Restore](../api-ref/Cluster/restore.md) method, e.g., via the following [cURL](https://curl.se/) request:

        ```bash
        curl \
            --request POST \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --header "Content-Type: application/json" \
            --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters:restore' \
            --data "@body.json"
        ```

    1. Check the [server response](../api-ref/Cluster/restore.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Create a file named `body.json` and paste the following code into it:

        
        ```json
        {
          "backup_id": "<backup_ID>",
          "time": "<time>",
          "folder_id": "<folder_ID>",
          "name": "<cluster_name>",
          "environment": "<environment>",
          "network_id": "<network_ID>",
          "config": {
            "zone_id": "<availability_zone>",
            "subnet_id": "<subnet_ID>",
            "assign_public_ip": "<enable_public_access_to_cluster_hosts>"
          },
          "master_resources": {
            "resource_preset_id": "<host_class>",
            "disk_size": "<storage_size_in_bytes>",
            "disk_type_id": "<disk_type>"
          },
          "segment_resources": {
            "resource_preset_id": "<host_class>",
            "disk_size": "<storage_size_in_bytes>",
            "disk_type_id": "<disk_type>"
          },
          "segment_host_count": "<number_of_segment_hosts>",
          "segment_in_host": "<number_of_segments_per_host>",
          "restore_only": [
            "<DB_and_table_1>",
            "<DB_and_table_2>",
            ...
            "<DB_and_table_N>"
          ],
          "master_host_group_ids": [
            "string"
          ],
          "segment_host_group_ids": [
            "string"
          ],
          "service_account_id": "<service_account_ID>"
        }
        ```


        Where:

        * `backup_id`: [Backup](../concepts/backup.md) ID. You can get it with the [list of backups](#list-backups).
        * `time`: Time point to restore the Yandex MPP Analytics for PostgreSQL cluster to, in `yyyy-mm-ddThh:mm:ssZ` format. By default, the cluster will be restored to the backup state.
        * `folder_id`: ID of the folder you want to restore the cluster to. You can request the ID with the [list of folders in the cloud](../../resource-manager/operations/folder/get-id.md). By default, the cluster is restored to the same folder the backup is in.
        * `name`: Name of the new cluster.
        * `environment`: Environment:

            * `PRESTABLE`: For testing purposes. The prestable environment is similar to the production environment and likewise covered by an SLA, but it is the first to get new features, improvements, and bug fixes. In the prestable environment, you can test new versions for compatibility with your application.
            * `PRODUCTION`: For stable versions of your applications.

        * `network_id`: [Network](../../vpc/concepts/network.md#network) ID.
        * `config`: Cluster settings:

            * `zone_id`: [Availability zone](../../overview/concepts/geo-scope.md).
            * `subnet_id`: [Subnet](../../vpc/concepts/network.md#subnet) ID.
            * `assign_public_ip`: Public access to cluster hosts, `true` or `false`.

        * `master_resources`, `segment_resources`: Master and segment host configuration in the cluster:

            * `resource_preset_id`: [Host class](../concepts/instance-types.md).
            * `disk_size`: Disk size, in bytes.
            * `disk_type_id`: [Disk type](../concepts/storage.md).

        * `segment_host_count`: Number of segment hosts, from `2` to `32`.
        * `segment_in_host`: [Number of segments per host](../concepts/index.md). The maximum value of this setting depends on the host class.

            The segment host class and the number of segments per host [affect](../concepts/instance-types.md#select-class-segment-hosts) the maximum amount of memory allocated to each Yandex MPP Analytics for PostgreSQL server process. If you select a host class with small RAM and specify a large number of segments, an [error](../qa/cluster-hosts.md#memory-limit) may occur.

        * `restore_only`: List of DBs and tables to restore from the backup. This is an optional setting. Supported formats: `<DB>/<schema>/<table>`, `<DB>/<table>`, and `<DB>`. You may use the `*` wildcard symbol as well. If you omit this setting, the whole cluster will be restored.

        
        * `master_host_group_ids` and `segment_host_group_ids`: IDs of [dedicated host](../../compute/concepts/dedicated-host.md) groups for master and segment hosts. This is an optional setting.

            You must first [create](../../compute/operations/dedicated-host/create-host-group.md) a group of dedicated hosts in Yandex Compute Cloud.

            You cannot edit this setting after you create a cluster. 
            
            If using dedicated hosts, the cluster cost is a sum of the charge for [computing resources Yandex Compute Cloud](../../compute/pricing.md#prices-dedicated-host) and the [markup Yandex MPP Analytics for PostgreSQL](../pricing/index.md#dedicated-hosts).

        * `service_account_id`: Service account ID.

        * `logging`: Settings for [transferring logs to Yandex Cloud Logging](mgp-to-cloud-logging.md):

            * `enabled`: Manages log transfer, `true` or `false`. To enable parameters responsible for transferring specific logs, provide the `true` value.
            * `command_center_enabled`: Transferring [Command Center](../concepts/command-center.md) logs, `true` or `false`.
            * `greenplum_enabled`: Transferring DBMS logs, `true` or `false`.
            * `pooler_enabled`: Transferring [connection pooler](../concepts/pooling.md) logs, `true` or `false`.
            * `folder_id`: Specify the ID of the folder whose log group you want to use.
            * `log_group_id`: ID of the log group to write logs to.

                Specify either `folder_id` or `log_group_id`.


    1. Call the [ClusterService.Restore](../api-ref/grpc/Cluster/restore.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        ```bash
        grpcurl \
            -format json \
            -import-path ~/cloudapi/ \
            -import-path ~/cloudapi/third_party/googleapis/ \
            -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/cluster_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d @ \
            mdb.api.cloud.yandex.net:443 \
            yandex.cloud.mdb.greenplum.v1.ClusterService.Restore \
            < body.json
        ```

    1. Check the [server response](../api-ref/grpc/Cluster/restore.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}