> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Backups in Managed Service for PostgreSQL®

Managed Service for PostgreSQL protects the data that you store in your clusters and creates backups for them. The service supports two types of backups:

* Automatic backups that Managed Service for PostgreSQL creates daily based on the [cluster configuration](#how-to-configure-automatic-backups) that you set.
* Manual (or on-demand) backups that you [create](#how-to-create-a-backup). You can also [delete](#how-to-delete-a-manual-backup) them later.

Once a backup is created, you can [restore a cluster](#how-to-restore-a-cluster-from-a-backup) from it.

## Prerequisites

If you use the web console, you don't need to complete any prerequisites.

If you use the CLI, Terraform, or an SDK, install and configure one of the following tools:

> [tab] CLI
>
> [Install and configure](https://docs.nebius.com/cli/install.md) the Nebius AI Cloud CLI.

> [tab] Terraform
>
> [Install and configure](https://docs.nebius.com/terraform-provider/install.md) the Nebius AI Cloud provider for Terraform.

> [tab] Go SDK
>
> [Install and initialize the Nebius SDK for Go](https://docs.nebius.com/sdk/go/install-auth.md).

> [tab] Python SDK
>
> [Install and initialize the Nebius SDK for Python](https://docs.nebius.com/sdk/python/install-auth.md).

> [tab] JavaScript SDK
>
> [Install and initialize the Nebius SDK for JavaScript](https://docs.nebius.com/sdk/javascript/install-auth.md).

## How to configure automatic backups

When you [create a Managed PostgreSQL cluster](https://docs.nebius.com/postgresql/clusters/manage.md#how-to-create-clusters), you can configure at what time of day the service creates automatic backups and how long it stores them.

> [!WARNING]
>
> You cannot change the backup settings after you create a cluster.

> [tab] Web console
>
> On the cluster creation page ( **PostgreSQL** → **Create cluster**), find **Backup settings**.
>
> You can configure the following settings of automatic backups:
>
> ***Start of backup window***
>
> Time when Managed PostgreSQL starts creating automatic backups. The service backs up clusters daily. The time is specified in UTC+00:00. Format: `HH:MM:SS`; for example, `00:30:00`. Default value: `00:02:00`.
>
> ***Retention period***
>
> Number of days Managed PostgreSQL stores an automatic backup after creating it. This is how far back you can restore the cluster. The retention period also applies to the cluster's [write ahead log](https://www.postgresql.org/docs/current/continuous-archiving.html) (WAL). Default and minimum value: `7d` (7 days). Maximum value: `30d` (30 days).

> [tab] CLI
>
> Add parameters of automatic backups to the cluster creation command:
>
> ```bash theme={null}
> nebius msp postgresql v1alpha1 cluster create \
>   --backup-backup-window-start '00:02:00' \
>   --backup-retention-policy '7d' \
>   <other_parameters>
> ```
>
> `--backup-backup-window-start`
>
> Time when Managed PostgreSQL starts creating automatic backups. The service backs up clusters daily. The time is specified in UTC+00:00. Format: `HH:MM:SS`; for example, `00:30:00`. Default value: `00:02:00`.
>
> `--backup-retention-policy`
>
> Number of days Managed PostgreSQL stores an automatic backup after creating it. This is how far back you can restore the cluster. The retention period also applies to the cluster's [write ahead log](https://www.postgresql.org/docs/current/continuous-archiving.html) (WAL). Default and minimum value: `7d` (7 days). Maximum value: `30d` (30 days).
>
> See the [full reference](https://docs.nebius.com/cli/reference/msp/postgresql/v1alpha1/cluster/create.md) for the command.

> [tab] Terraform
>
> Add parameters of automatic backups to the cluster resource:
>
> ```bash theme={null}
> resource "nebius_msp_postgresql_v1alpha1_cluster" "<resource_name>" {
>   backup = {
>     backup_window_start = "00:02:00"
>     retention_policy    = "7d"
>   }
>
>   <other_parameters>
> }
> ```
>
> `backup.backup_window_start`
>
> Time when Managed PostgreSQL starts creating automatic backups. The service backs up clusters daily. The time is specified in UTC+00:00. Format: `HH:MM:SS`; for example, `00:30:00`. Default value: `00:02:00`.
>
> `backup.retention_policy`
>
> Number of days Managed PostgreSQL stores an automatic backup after creating it. This is how far back you can restore the cluster. The retention period also applies to the cluster's [write ahead log](https://www.postgresql.org/docs/current/continuous-archiving.html) (WAL). Default and minimum value: `7d` (7 days). Maximum value: `30d` (30 days).
>
> See the [full reference](https://docs.nebius.com/terraform-provider/reference/resources/msp_postgresql_v1alpha1_cluster.md) for the resource.

> [tab] Go SDK
>
> Add automatic backup settings when creating a cluster:
>
> ```go theme={null}
> createService := sdk.Services().MSP().PostgreSQL().
>     V1Alpha1().Cluster()
> createRequest := &pg.CreateClusterRequest{
>     Metadata: &common.ResourceMetadata{
>         ParentId: "<project_ID>",
>         Name: "<cluster_name>",
>     },
>     Spec: &pg.ClusterSpec{
>         NetworkId: "<network_ID>",
>         Config: &pg.ConfigSpec{
>             Version: "16",
>             PoolerConfig: &pg.ConnectionPoolerConfig{
>                 PoolingMode:
>                     pg.ConnectionPoolerConfig_SESSION,
>                 MaxPoolSize: proto.Int64(5),
>             },
>             PublicAccess: false,
>             Template: &pg.TemplateSpec{
>                 Resources: &resource.ResourcesSpec{
>                     Platform: "cpu-e2",
>                     Preset: "2vcpu-8gb",
>                 },
>                 Disk: &resource.DiskSpec{
>                     Type: "network-ssd",
>                     SizeGibibytes: 20,
>                 },
>                 Hosts: &resource.HostSpec{
>                     Count: 1,
>                 },
>             },
>         },
>         Bootstrap: &pg.BootstrapSpec{
>             DbName: "<database_name>",
>             UserName: "<username>",
>             UserPassword: "<password>",
>         },
>         Backup: &pg.BackupSpec{
>             BackupWindowStart: "00:02:00",
>             RetentionPolicy: "7d",
>         },
>     },
> }
> createOperation, err := createService.Create(
>     ctx, createRequest,
> )
> if err != nil {
>     return fmt.Errorf("create cluster: %w", err)
> }
> _, err = createOperation.Wait(ctx)
> if err != nil {
>     return fmt.Errorf("wait for cluster creation: %w", err)
> }
> ```
>
> In the code, update the following values:
>
> * `Metadata.ParentId`: Project ID.
> * `Metadata.Name`: Cluster name.
> * `Spec.NetworkId`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-go-sdk).
> * `Spec.Bootstrap.DbName`: Database name.
> * `Spec.Bootstrap.UserName`: Username.
> * `Spec.Bootstrap.UserPassword`: Database password.
> * `Spec.Backup.BackupWindowStart`: Backup schedule, in `HH:MM:SS` format.
> * `Spec.Backup.RetentionPolicy`: Backup retention period, for example `7d`.

> [tab] Python SDK
>
> Add automatic backup settings when creating a cluster:
>
> ```python theme={null}
> create_service = pg.ClusterServiceClient(sdk)
> create_request = pg.CreateClusterRequest(
>     metadata=ResourceMetadata(
>         parent_id="<project_ID>",
>         name="<cluster_name>",
>     ),
>     spec=pg.ClusterSpec(
>         network_id="<network_ID>",
>         config=pg.ConfigSpec(
>             version="16",
>             pooler_config=pg.ConnectionPoolerConfig(
>                 pooling_mode=(
>                     pg.ConnectionPoolerConfig.PoolingMode.
>                     SESSION
>                 ),
>                 max_pool_size=5,
>             ),
>             public_access=False,
>             template=pg.TemplateSpec(
>                 resources=resource.ResourcesSpec(
>                     platform="cpu-e2",
>                     preset="2vcpu-8gb",
>                 ),
>                 disk=resource.DiskSpec(
>                     type="network-ssd",
>                     size_gibibytes=20,
>                 ),
>                 hosts=resource.HostSpec(
>                     count=1,
>                 ),
>             ),
>         ),
>         bootstrap=pg.BootstrapSpec(
>             db_name="<database_name>",
>             user_name="<username>",
>             user_password="<password>",
>         ),
>         backup=pg.BackupSpec(
>             backup_window_start="00:02:00",
>             retention_policy="7d",
>         ),
>     ),
> )
> create_operation = await create_service.create(create_request)
> await create_operation.wait()
> ```
>
> In the code, update the following values:
>
> * `metadata.parent_id`: Project ID.
> * `metadata.name`: Cluster name.
> * `spec.network_id`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-python-sdk).
> * `spec.bootstrap.db_name`: Database name.
> * `spec.bootstrap.user_name`: Username.
> * `spec.bootstrap.user_password`: Database password.
> * `spec.backup.backup_window_start`: Backup schedule, in `HH:MM:SS` format.
> * `spec.backup.retention_policy`: Backup retention period, for example `7d`.

> [tab] JavaScript SDK
>
> Add automatic backup settings when creating a cluster:
>
> ```ts theme={null}
> const createService = new pg.ClusterService(sdk);
> const createRequest = pg.CreateClusterRequest.create({
>   metadata: {
>     parentId: "<project_ID>",
>     name: "<cluster_name>",
>   },
>   spec: {
>     networkId: "<network_ID>",
>     config: {
>       version: "16",
>       poolerConfig: {
>         poolingMode:
>           pg.ConnectionPoolerConfig_PoolingMode.SESSION,
>         maxPoolSize: Long.fromNumber(5),
>       },
>       publicAccess: false,
>       template: {
>         resources: {
>           platform: "cpu-e2",
>           preset: "2vcpu-8gb",
>         },
>         disk: {
>           type: "network-ssd",
>           sizeGibibytes: Long.fromNumber(20),
>         },
>         hosts: {
>           count: Long.fromNumber(1),
>         },
>       },
>     },
>     bootstrap: {
>       dbName: "<database_name>",
>       userName: "<username>",
>       userPassword: "<password>",
>     },
>     backup: {
>       backupWindowStart: "00:02:00",
>       retentionPolicy: "7d",
>     },
>   },
> });
> const createOperation = await createService.create(
>   createRequest,
> ).result;
> await createOperation.wait();
> ```
>
> In the code, update the following values:
>
> * `metadata.parentId`: Project ID.
> * `metadata.name`: Cluster name.
> * `spec.networkId`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-javascript-sdk).
> * `spec.bootstrap.dbName`: Database name.
> * `spec.bootstrap.userName`: Username.
> * `spec.bootstrap.userPassword`: Database password.
> * `spec.backup.backupWindowStart`: Backup schedule, in `HH:MM:SS` format.
> * `spec.backup.retentionPolicy`: Backup retention period, for example `7d`.

## How to create a backup

Before you begin, make sure that your Managed PostgreSQL cluster has the `Running` status.

To create a backup:

> [tab] Web console
>
> 1. In the sidebar, go to  **PostgreSQL**.
> 2. Open the page of the required cluster and then go to the **Backups** tab.
> 3. Click  **Create backup**.
>
> After that, a new backup appears in the list.

> [tab] CLI
>
> 1. To get the ID of the required cluster, list the Managed PostgreSQL clusters:
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 cluster list
>    ```
>    The cluster ID is specified in the `metadata.id` parameter.
> 2. Create a backup:
>
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 backup create --cluster-id <cluster_ID>
>    ```

> [tab] Go SDK
>
> ```go theme={null}
> createBackupService := sdk.Services().MSP().PostgreSQL().
>     V1Alpha1().Backup()
> createBackupOperation, err := createBackupService.Create(
>     ctx,
>     &pg.CreateBackupRequest{
>         ClusterId: "<cluster_ID>",
>     },
> )
> if err != nil {
>     return fmt.Errorf("create: %w", err)
> }
> _, err = createBackupOperation.Wait(ctx)
> if err != nil {
>     return fmt.Errorf("wait for create: %w", err)
> }
> ```
>
> In the code, set `CreateBackupRequest.ClusterId` to the cluster ID.

> [tab] Python SDK
>
> ```python theme={null}
> create_backup_service = pg.BackupServiceClient(sdk)
> create_backup_operation = await create_backup_service.create(
>     pg.CreateBackupRequest(
>         cluster_id="<cluster_ID>",
>     ),
> )
> await create_backup_operation.wait()
> ```
>
> In the code, set `CreateBackupRequest.cluster_id` to the cluster ID.

> [tab] JavaScript SDK
>
> ```ts theme={null}
> const createBackupService = new pg.BackupService(sdk);
> const createBackupOperation = await createBackupService.create(
>   pg.CreateBackupRequest.create({
>     clusterId: "<cluster_ID>",
>   }),
> ).result;
> await createBackupOperation.wait();
> ```
>
> In the code, set `CreateBackupRequest.clusterId` to the cluster ID.

## How to restore a cluster from a backup

When you restore from a backup, you create a new Managed PostgreSQL cluster. In this new cluster, the target host disks must be at least as large as the source host disks. You can configure the rest of the settings differently from the source cluster.

You can restore from a backup not only existing clusters, but also deleted ones. After you delete a cluster, Managed PostgreSQL stores its backups for the [retention period](#how-to-configure-automatic-backups).

To restore a cluster from a backup:

> [tab] Web console
>
> 1. In the sidebar, go to  **PostgreSQL**.
>
> 2. Switch to **Backups**. Alternatively, open the page of the required cluster and switch to **Backups**.
>
> 3. Launch restoration:
>
>    * For an automatic backup, click **Restore**.
>    * For a manual backup, click  → **Restore**.
>
> 4. In the form that opens, configure and create a new cluster that will be restored from the backup. For configuration details, see [Working with your Managed Service for PostgreSQL® cluster](https://docs.nebius.com/postgresql/clusters/manage.md).
>
>    When you fill out the form for an automatic backup, you can specify an optional *recovery time*. This is the moment to which the cluster state should be returned.
>
>    Managed PostgreSQL supports the [Point-in-Time Recovery](https://en.wikipedia.org/wiki/Point-in-time_recovery) (PITR) technology. This technology allows you to restore a cluster to any moment, from creation of the oldest backup to archiving the most recent [write-ahead log (WAL)](https://www.postgresql.org/docs/current/wal-intro.html).
>
>    If you specify a desired time and receive the error that a WAL has not been archived yet, wait a while for the WAL to be archived. The archiving process takes some time, especially if the cluster does not have any workloads.

> [tab] CLI
>
> 1. Get IDs of the backup and its source cluster. For example, you can:
>
>    * List all Managed PostgreSQL backups in the project:
>
>      ```bash theme={null}
>      nebius msp postgresql v1alpha1 backup list
>      ```
>
>    * List all backups of the specified cluster:
>
>      ```bash theme={null}
>      nebius msp postgresql v1alpha1 backup list-by-cluster \
>        --cluster-id <cluster_ID>
>      ```
>
>      To get the cluster ID, use [nebius msp postgresql v1alpha1 cluster list](https://docs.nebius.com/cli/reference/msp/postgresql/v1alpha1/cluster/list.md) or [nebius msp postgresql v1alpha1 cluster get-by-name](https://docs.nebius.com/cli/reference/msp/postgresql/v1alpha1/cluster/get-by-name.md).
>
>    Both commands that list backups return outputs like the following:
>
>    ```yaml theme={null}
>    backups:
>      - id: <backup_ID>
>        source_cluster_id: <ID_of_source_cluster>
>        ...
>    ```
>
> 2. Restore the cluster:
>
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 cluster restore \
>      --backup-id <backup_ID> \
>      --source-cluster-id <ID_of_source_cluster> \
>      --name <cluster_name> \
>      --bootstrap-user-password *** \
>      --network-id vpcnetwork-e*** \
>      --recovery-time <yyyy-mm-dd>T<hh:mm:ss>Z
>    ```
>
>    The command contains the following parameters:
>
>    * `--backup-id`: ID of the backup that you got in the previous step.
>
>    * `--source-cluster-id`: ID of the source PostgreSQL cluster.
>
>    * `--name`: Name of the new PostgreSQL cluster created from the backup.
>
>    * `--bootstrap-user-password`: PostgreSQL user password. It does not have to repeat the password of the source cluster.
>
>      The password must contain at least:
>
>      * 8 characters
>      * One lowercase character
>      * One uppercase character
>      * One special character
>
>    * `--network-id`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-cli).
>
>    * `--recovery-time` (optional; for automatic backups only): Moment to which the cluster state should be returned.
>
>      Managed PostgreSQL supports the [Point-in-Time Recovery](https://en.wikipedia.org/wiki/Point-in-time_recovery) (PITR) technology. This technology allows you to restore a cluster to any moment, from creation of the oldest backup to archiving the most recent [write-ahead log (WAL)](https://www.postgresql.org/docs/current/wal-intro.html).
>
>      If you specify a desired time and receive the error that a WAL has not been archived yet, wait a while for the WAL to be archived. The archiving process takes some time, especially if the cluster does not have any workloads.

> [tab] Go SDK
>
> 1. Get IDs of the backup and its source cluster. For example, you can:
>
>    * List all Managed PostgreSQL backups in the project:
>
>      ```go theme={null}
>      listBackupService := sdk.Services().MSP().PostgreSQL().
>          V1Alpha1().Backup()
>      listBackupResponse, err := listBackupService.List(
>          ctx,
>          &pg.ListBackupsRequest{
>              ParentId: "<project_ID>",
>          },
>      )
>      if err != nil {
>          return fmt.Errorf("list: %w", err)
>      }
>      fmt.Println(listBackupResponse)
>      ```
>
>    * Get the cluster ID:
>
>      ```go theme={null}
>      listClusterService := sdk.Services().MSP().PostgreSQL().
>          V1Alpha1().Cluster()
>      listClusterResponse, err := listClusterService.List(
>          ctx,
>          &pg.ListClustersRequest{
>              ParentId: "<project_ID>",
>          },
>      )
>      if err != nil {
>          return fmt.Errorf("list: %w", err)
>      }
>      fmt.Println(listClusterResponse)
>      ```
>
>      Then list all backups of the specified cluster:
>
>      ```go theme={null}
>      byClusterService := sdk.Services().MSP().PostgreSQL().
>          V1Alpha1().Backup()
>      byClusterResponse, err := byClusterService.ListByCluster(
>          ctx,
>          &pg.ListBackupsByClusterRequest{
>              ClusterId: "<cluster_ID>",
>          },
>      )
>      if err != nil {
>          return fmt.Errorf("list by cluster: %w", err)
>      }
>      fmt.Println(byClusterResponse)
>      ```
> 2. Restore the cluster:
>
>    ```go theme={null}
>    restoreService := sdk.Services().MSP().PostgreSQL().
>        V1Alpha1().Cluster()
>    restoreRequest := &pg.RestoreClusterRequest{
>        Metadata: &common.ResourceMetadata{
>            ParentId: "<project_ID>",
>            Name: "<cluster_name>",
>        },
>        Spec: &pg.ClusterSpec{
>            NetworkId: "vpcnetwork-e***",
>            Bootstrap: &pg.BootstrapSpec{
>                UserPassword: "***",
>            },
>        },
>        BackupId: "<backup_ID>",
>        SourceClusterId: "<ID_of_source_cluster>",
>    }
>    parsedTime, err := time.Parse(
>        time.RFC3339, "<yyyy-mm-dd>T<hh:mm:ss>Z",
>    )
>    if err != nil {
>        return fmt.Errorf("parse recovery time: %w", err)
>    }
>    restoreRequest.RecoveryTime = timestamppb.New(parsedTime)
>    restoreOperation, err := restoreService.Restore(
>        ctx, restoreRequest,
>    )
>    if err != nil {
>        return fmt.Errorf("restore cluster: %w", err)
>    }
>    _, err = restoreOperation.Wait(ctx)
>    if err != nil {
>        return fmt.Errorf("wait for cluster restore: %w", err)
>    }
>    ```
>
>    In the code, update the following values:
>
>    * `Metadata.ParentId`: Project ID.
>    * `Metadata.Name`: New cluster name.
>    * `Spec.NetworkId`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-go-sdk).
>    * `Spec.Bootstrap.UserPassword`: PostgreSQL user password.
>    * `BackupId`: Backup ID.
>    * `SourceClusterId`: Source cluster ID.
>    * `RecoveryTime` (optional; for automatic backups only): Moment to which the cluster state should be returned.

> [tab] Python SDK
>
> 1. Get IDs of the backup and its source cluster. For example, you can:
>
>    * List all Managed PostgreSQL backups in the project:
>
>      ```python theme={null}
>      list_backup_service = pg.BackupServiceClient(sdk)
>      list_backup_response = await list_backup_service.list(
>          pg.ListBackupsRequest(
>              parent_id="<project_ID>",
>          ),
>      )
>      print(list_backup_response)
>      ```
>
>    * Get the cluster ID:
>
>      ```python theme={null}
>      list_cluster_service = pg.ClusterServiceClient(sdk)
>      list_cluster_response = await list_cluster_service.list(
>          pg.ListClustersRequest(
>              parent_id="<project_ID>",
>          ),
>      )
>      print(list_cluster_response)
>      ```
>
>      Then list all backups of the specified cluster:
>
>      ```python theme={null}
>      by_cluster_service = pg.BackupServiceClient(sdk)
>      by_cluster_response = await by_cluster_service.list_by_cluster(
>          pg.ListBackupsByClusterRequest(
>              cluster_id="<cluster_ID>",
>          ),
>      )
>      print(by_cluster_response)
>      ```
> 2. Restore the cluster:
>
>    ```python theme={null}
>    restore_service = pg.ClusterServiceClient(sdk)
>    restore_request = pg.RestoreClusterRequest(
>        metadata=ResourceMetadata(
>            parent_id="<project_ID>",
>            name="<cluster_name>",
>        ),
>        spec=pg.ClusterSpec(
>            network_id="vpcnetwork-e***",
>            bootstrap=pg.BootstrapSpec(
>                user_password="***",
>            ),
>        ),
>        backup_id="<backup_ID>",
>        source_cluster_id="<ID_of_source_cluster>",
>    )
>    restore_request.recovery_time = datetime.fromisoformat(
>        "<yyyy-mm-dd>T<hh:mm:ss>Z".replace("Z", "+00:00"),
>    )
>    restore_operation = await restore_service.restore(restore_request)
>    await restore_operation.wait()
>    ```
>
>    In the code, update the following values:
>
>    * `metadata.parent_id`: Project ID.
>    * `metadata.name`: New cluster name.
>    * `spec.network_id`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-python-sdk).
>    * `spec.bootstrap.user_password`: PostgreSQL user password.
>    * `backup_id`: Backup ID.
>    * `source_cluster_id`: Source cluster ID.
>    * `recovery_time` (optional; for automatic backups only): Moment to which the cluster state should be returned.

> [tab] JavaScript SDK
>
> 1. Get IDs of the backup and its source cluster. For example, you can:
>
>    * List all Managed PostgreSQL backups in the project:
>
>      ```ts theme={null}
>      const listBackupService = new pg.BackupService(sdk);
>      const listBackupResponse = await listBackupService.list(
>        pg.ListBackupsRequest.create({
>          parentId: "<project_ID>",
>        }),
>      ).result;
>      console.log(listBackupResponse);
>      ```
>
>    * Get the cluster ID:
>
>      ```ts theme={null}
>      const listClusterService = new pg.ClusterService(sdk);
>      const listClusterResponse = await listClusterService.list(
>        pg.ListClustersRequest.create({
>          parentId: "<project_ID>",
>        }),
>      ).result;
>      console.log(listClusterResponse);
>      ```
>
>      Then list all backups of the specified cluster:
>
>      ```ts theme={null}
>      const byClusterService = new pg.BackupService(sdk);
>      const byClusterResponse = await byClusterService.listByCluster(
>        pg.ListBackupsByClusterRequest.create({
>          clusterId: "<cluster_ID>",
>        }),
>      ).result;
>      console.log(byClusterResponse);
>      ```
> 2. Restore the cluster:
>
>    ```ts theme={null}
>    const restoreService = new pg.ClusterService(sdk);
>    const restoreRequest = pg.RestoreClusterRequest.create({
>      metadata: {
>        parentId: "<project_ID>",
>        name: "<cluster_name>",
>      },
>      spec: {
>        networkId: "vpcnetwork-e***",
>        bootstrap: { userPassword: "***" },
>      },
>      backupId: "<backup_ID>",
>      sourceClusterId: "<ID_of_source_cluster>",
>    });
>    restoreRequest.recoveryTime = dayjs("<yyyy-mm-dd>T<hh:mm:ss>Z");
>    const restoreOperation = await restoreService.restore(
>      restoreRequest,
>    ).result;
>    await restoreOperation.wait();
>    ```
>
>    In the code, update the following values:
>
>    * `metadata.parentId`: Project ID.
>    * `metadata.name`: New cluster name.
>    * `spec.networkId`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-javascript-sdk).
>    * `spec.bootstrap.userPassword`: PostgreSQL user password.
>    * `backupId`: Backup ID.
>    * `sourceClusterId`: Source cluster ID.
>    * `recoveryTime` (optional; for automatic backups only): Moment to which the cluster state should be returned.

## How to delete a manual backup

You can only delete manual backups that you created. You cannot delete automatic backups.

Conversely, Managed PostgreSQL cannot delete manual backups, only automatic ones.

To delete a manual backup:

> [tab] Web console
>
> 1. In the sidebar, go to  **PostgreSQL**.
> 2. Open the page of the required cluster and then go to the **Backups** tab.
> 3. In the row of the required manual backup, click  → **Delete**.
>
> After that, the deletion confirmation is displayed. The backup is deleted in a few seconds.

> [tab] CLI
>
> 1. To get the ID of the required cluster, list the Managed PostgreSQL clusters:
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 cluster list
>    ```
>    The cluster ID is specified in the `metadata.id` parameter.
>
> 2. To get the ID of the required manual backup, list the backups of the selected cluster:
>
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 backup list-by-cluster \
>      --cluster-id <cluster_ID>
>    ```
>
>    The backup ID is specified in the `id` parameter.
>
>    Select only backups with the `on_demand: true` parameter. This means that they are manual.
>
> 3. Delete the backup:
>
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 backup delete \
>      --cluster-id <cluster_ID> --backup-id <backup_ID>
>    ```

> [tab] Go SDK
>
> 1. Get the ID of the required manual backup. To do this:
>
>    1. Get the cluster ID:
>
>       ```go theme={null}
>       listClusterService := sdk.Services().MSP().PostgreSQL().
>           V1Alpha1().Cluster()
>       listClusterResponse, err := listClusterService.List(
>           ctx,
>           &pg.ListClustersRequest{
>               ParentId: "<project_ID>",
>           },
>       )
>       if err != nil {
>           return fmt.Errorf("list: %w", err)
>       }
>       fmt.Println(listClusterResponse)
>       ```
>
>    2. Then list all backups of the selected cluster:
>
>       ```go theme={null}
>       byClusterService := sdk.Services().MSP().PostgreSQL().
>           V1Alpha1().Backup()
>       byClusterResponse, err := byClusterService.ListByCluster(
>           ctx,
>           &pg.ListBackupsByClusterRequest{
>               ClusterId: "<cluster_ID>",
>           },
>       )
>       if err != nil {
>           return fmt.Errorf("list by cluster: %w", err)
>       }
>       fmt.Println(byClusterResponse)
>       ```
>
>       Select only backups with the `on_demand: true` parameter. This means that they are manual.
> 2. Delete the backup:
>
>    ```go theme={null}
>    deleteBackupService := sdk.Services().MSP().PostgreSQL().
>        V1Alpha1().Backup()
>    deleteBackupOperation, err := deleteBackupService.Delete(
>        ctx,
>        &pg.DeleteBackupRequest{
>            ClusterId: "<cluster_ID>",
>            BackupId: "<backup_ID>",
>        },
>    )
>    if err != nil {
>        return fmt.Errorf("delete: %w", err)
>    }
>    _, err = deleteBackupOperation.Wait(ctx)
>    if err != nil {
>        return fmt.Errorf("wait for delete: %w", err)
>    }
>    ```
>
>    In the code, update the following values:
>
>    * `DeleteBackupRequest.ClusterId`: Cluster ID.
>    * `DeleteBackupRequest.BackupId`: Backup ID.

> [tab] Python SDK
>
> 1. Get the ID of the required manual backup. To do this:
>
>    1. Get the cluster ID:
>
>       ```python theme={null}
>       list_cluster_service = pg.ClusterServiceClient(sdk)
>       list_cluster_response = await list_cluster_service.list(
>           pg.ListClustersRequest(
>               parent_id="<project_ID>",
>           ),
>       )
>       print(list_cluster_response)
>       ```
>
>    2. Then list all backups of the selected cluster:
>
>       ```python theme={null}
>       by_cluster_service = pg.BackupServiceClient(sdk)
>       by_cluster_response = await by_cluster_service.list_by_cluster(
>           pg.ListBackupsByClusterRequest(
>               cluster_id="<cluster_ID>",
>           ),
>       )
>       print(by_cluster_response)
>       ```
>
>       Select only backups with the `on_demand: true` parameter. This means that they are manual.
> 2. Delete the backup:
>
>    ```python theme={null}
>    delete_backup_service = pg.BackupServiceClient(sdk)
>    delete_backup_operation = await delete_backup_service.delete(
>        pg.DeleteBackupRequest(
>            cluster_id="<cluster_ID>",
>            backup_id="<backup_ID>",
>        ),
>    )
>    await delete_backup_operation.wait()
>    ```
>
>    In the code, update the following values:
>
>    * `DeleteBackupRequest.cluster_id`: Cluster ID.
>    * `DeleteBackupRequest.backup_id`: Backup ID.

> [tab] JavaScript SDK
>
> 1. Get the ID of the required manual backup. To do this:
>
>    1. Get the cluster ID:
>
>       ```ts theme={null}
>       const listClusterService = new pg.ClusterService(sdk);
>       const listClusterResponse = await listClusterService.list(
>         pg.ListClustersRequest.create({
>           parentId: "<project_ID>",
>         }),
>       ).result;
>       console.log(listClusterResponse);
>       ```
>
>    2. Then list all backups of the selected cluster:
>
>       ```ts theme={null}
>       const byClusterService = new pg.BackupService(sdk);
>       const byClusterResponse = await byClusterService.listByCluster(
>         pg.ListBackupsByClusterRequest.create({
>           clusterId: "<cluster_ID>",
>         }),
>       ).result;
>       console.log(byClusterResponse);
>       ```
>
>       Select only backups with the `on_demand: true` parameter. This means that they are manual.
> 2. Delete the backup:
>
>    ```ts theme={null}
>    const deleteBackupService = new pg.BackupService(sdk);
>    const deleteBackupOperation = await deleteBackupService.delete(
>      pg.DeleteBackupRequest.create({
>        clusterId: "<cluster_ID>",
>        backupId: "<backup_ID>",
>      }),
>    ).result;
>    await deleteBackupOperation.wait();
>    ```
>
>    In the code, update the following values:
>
>    * `DeleteBackupRequest.clusterId`: Cluster ID.
>    * `DeleteBackupRequest.backupId`: Backup ID.

***

*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.*
