Instead of using migration, you can replicate data from an external cluster to a Managed PostgreSQL cluster.
Steps
Prerequisites
The migration is only possible if the following conditions are met:- The PostgreSQL version in the source cluster is the same as in the target cluster. You can check the versions supported by Managed PostgreSQL on the cluster creation page in the web console.
-
The
pg_dumpandpg_restoreutilities have the same version. You can install these utilities together withpsql:- macOS
- Ubuntu
After that, restart the terminal. - The major version of the utilities must be greater than or equal to the PostgreSQL version in the target cluster. For example, if the cluster is created with version 16, the major version of the utilities can be 16 or 17.
Prepare a target cluster
- Create a target cluster with the same username as in the source cluster. For details on how to create a Managed Service for PostgreSQL cluster, see How to create clusters.
-
Make sure that the target cluster has at least the same list of installed PostgreSQL extensions as the source cluster does:
-
Connect to the DB in the source cluster and then check what extensions are installed:
- Enable these extensions on a target cluster.
-
Connect to the DB in the source cluster and then check what extensions are installed:
-
To secure connections to databases, install the Nebius AI Cloud certificate:
This command creates the
.postgresqlfolder, downloads the certificate into it and then sets the access rights to the certificate file.
Migrate data
-
Switch the source DB to read-only mode:
Run this statement for every DB user.
-
Create the source DB dump:
Specify the following parameters in the command:
--host: The IP address or FQDN of the primary host of the source cluster.--port: The port to access the source cluster.--dbname: The source DB name.--username: The username in the source cluster.--jobs(optional): To speed up the dump creation and activate a multithreaded mode, specify the number of vCPU cores on which dump creation threads run in parallel.
-
Restore the data from the dump to the target cluster:
Specify the following parameters in the command:
-
--host: The IP address or FQDN of the primary host of the target cluster. -
--dbname: The target DB name. -
--username: The username in the target cluster. Must match the username in the source cluster. If you restore all the data from the source DB, specify the DB owner username. If you only restore a single schema, add the--schema=<schema_name>parameter. In this case, the DB owner rights are not required.
--single-transactionparameter from the command. The service ignores the errors in this case:However, make sure that these errors only apply to the extensions. -
-
Connect to the target DB and check the integrity of the migrated data:
- To check the list of tables, run
\dt. - To check the list of schemas, run
\dn.
- To check the list of tables, run
Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.