Managing backups in Managed Service for PostgreSQL
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.
Restoring 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 in Managed Service for PostgreSQL.
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.
To restore an existing cluster from a backup:
-
Go to the folder page and select Managed Service for PostgreSQL.
-
Click the name of the cluster you need and select the Backup copies tab.
-
Click the
-
Set up the new cluster. You can select a folder for the new cluster from the Folder list.
-
To restore the cluster state from a desired point of time after creating this backup, configure the Date and time of recovery (UTC) setting. You can enter the value manually or select it from the drop-down calendar.
If you do not change the setting, the cluster is restored to the state when the backup was completed.
-
Click Restore cluster.
To restore a previously deleted cluster from a backup:
-
Go to the folder page and select Managed Service for PostgreSQL.
-
Click the Backups tab.
-
Find the backup you need using the backup creation time and cluster ID. The Name column contains the IDs in
<cluster ID>:<backup ID>
format. -
Click the
-
Set up the new cluster. You can select a folder for the new cluster from the Folder list.
-
To restore the cluster state from a desired point of time after creating this backup, configure the Date and time of recovery (UTC) setting. You can enter the value manually or select it from the drop-down calendar.
If you do not change the setting, the cluster is restored to the state when the backup was completed.
-
Click Restore cluster.
Managed Service for PostgreSQL launches the operation to create a cluster from the backup.
If you don't have the Nebius AI command line interface 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:
-
View a description of the CLI restore PostgreSQL cluster command:
ncp managed-postgresql cluster restore --help
-
Getting a list of available PostgreSQL cluster backups:
ncp managed-postgresql backup list
+-------------------------+---------------------+----------------------+---------------------+ | ID | CREATED AT | SOURCE CLUSTER ID | STARTED AT | +-------------------------+---------------------+----------------------+---------------------+ | c9qlk4v13uq79r9cgcku... | 2020-08-10 12:00:00 | c9qlk4v13uq79r9cgcku | 2020-08-10 11:55:17 | | ... | +-------------------------+---------------------+----------------------+---------------------+
The time when the backup was completed is shown in the
CREATED AT
column with a list of available backups, inyyyy-mm-dd hh:mm:ss
format (2020-08-10 12:00:00
in the example above). You can restore a cluster to any point in time starting with creation of its backup. -
Request the creation of a cluster from a backup:
ncp managed-postgresql cluster restore \ --backup-id=<backup ID> \ --time=<point in time to restore the PostgreSQL cluster to> \ --name=<cluster name> \ --network-name=<network name> \ --host zone-id=<availability zone>,` `subnet-name=<subnet name>,` `assign-public-ip=<public access to the host: true or false> \ --resource-preset=<host class> \ --disk-size=<storage size in GB> \ --disk-type=<disk type>
Where:
-
--backup-id
: Backup ID -
--time
: Point in time to which you need to restore a PostgreSQL cluster's state, inyyyy-mm-ddThh:mm:ssZ
format. -
--name
: Cluster name. -
--network-name
: Network name. -
--host
: Host parameters:-
zone-id
: Availability zone. -
subnet-name
: Name of the subnet. It must be specified if the selected availability zone includes two or more subnets. -
assign-public-ip
: Flag to be set if public access to the host is required.
-
-
--resource-preset
: host class. -
--disk-size
: Storage size in GB.
-
Creating a backup
- Go to the folder page and select Managed Service for PostgreSQL.
- Click the name of the cluster you need and select the Backup copies tab.
- Click Create backup.
The service will start creating a backup without an additional confirmation.
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To create a cluster backup:
-
View a description of the CLI create PostgreSQL backup command:
ncp managed-postgresql cluster backup --help
-
Request the creation of a backup specifying the cluster name or ID:
ncp managed-postgresql cluster backup my-pg-cluster
The cluster name and ID can be retrieved with the list of clusters.
Warning
While you are creating your backup, the cluster performance might degrade. In some cases, the cluster might become temporarily unavailable.
Getting a list of backups
To get a list of cluster backups:
- Go to the folder page and select Managed Service for PostgreSQL.
- Click the name of the cluster you need and select the Backup copies tab.
To get a list of all backups in a folder:
- Go to the folder page and select Managed Service for PostgreSQL.
- Click the Backups tab.
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To get a list of PostgreSQL cluster backups available in the default folder, run the command:
ncp managed-postgresql backup list
+----------+---------------------+----------------------+---------------------+
| ID | CREATED AT | SOURCE CLUSTER ID | STARTED AT |
+----------+---------------------+----------------------+---------------------+
| c9qlk... | 2020-08-10 12:00:00 | c9qlk4v13uq79r9cgcku | 2020-08-10 11:55:17 |
| c9qpm... | 2020-08-09 22:01:04 | c9qpm90p3pcg71jm7tqf | 2020-08-09 21:30:00 |
+----------+---------------------+----------------------+---------------------+
Getting information about backups
To get information about the backup of an existing cluster:
- Go to the folder page and select Managed Service for PostgreSQL.
- Click the name of the cluster you need and select the Backup copies tab.
To get information about the backup of a previously deleted cluster:
- Go to the folder page and select Managed Service for PostgreSQL.
- Click the Backups tab.
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To get information about a PostgreSQL cluster backup, run the command:
ncp managed-postgresql backup get <backup ID>
You can retrieve the backup ID with a list of backups.
Setting the backup start time
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.
ncp managed-postgresql cluster create \
--cluster-name <cluster name> \
--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=<database name>,owner=<database owner name> \
--disk-size <storage size, GB>
--backup-window-start 10:00:00
To change the backup start time in an existing cluster, use the update
command:
ncp managed-postgresql cluster update \
--cluster-name <cluster name> \
--backup-window-start 11:25:00
Deleting a backup
You can only delete backups that were created manually.
- Go to the folder page and select Managed Service for PostgreSQL.
- Select the Managed Service for PostgreSQL cluster whose backup you want to delete.
- In the left panel, select Backups.
- Click
- Select Delete backup.
- Confirm deletion and click Delete.