Use the one-click cloud migration feature to migrate a PostgreSQL database from ApsaraDB for MyBase (dedicated host) to a fully managed ApsaraDB RDS for PostgreSQL instance. The migration runs in three stages: feasibility assessment, data migration and cutover, and application reconnection.
Limitations
Instances of the General-purpose family do not support data migration over the internet.
During migration, do not perform data migration, instance restarts, or configuration changes on the source instance.
After you set the source instance to read-only, applications can no longer write data to it.
Prerequisites
Before you begin, ensure that you have:
A destination ApsaraDB RDS for PostgreSQL instance that meets all of the following requirements: For instructions, see Create an ApsaraDB RDS for PostgreSQL instance.
The same Version and Series as the source ApsaraDB for MyBase for PostgreSQL instance
Storage capacity larger than the used storage of the source instance
Instance family set to Dedicated Instance Types
Network connectivity between the two instances:
Internal network: The RDS instance must be in the same region and Virtual Private Cloud (VPC) as the MyBase instance.
Internet: Request public endpoints for both instances. See Apply for a public endpoint for an ApsaraDB RDS for PostgreSQL instance and Apply for a public endpoint for an ApsaraDB for MyBase for PostgreSQL instance.
Whitelists configured on both instances so that each can reach the other. See Configure a whitelist for an ApsaraDB RDS for PostgreSQL instance and Configure a whitelist for an ApsaraDB for MyBase for PostgreSQL instance. To find the CIDR block of an instance, go to the Database Connection page in the ApsaraDB RDS or ApsaraDB for MyBase console.

A privileged account for the source ApsaraDB for MyBase for PostgreSQL instance. See Create a database account.
Step 1: Run a feasibility assessment
The feasibility assessment verifies that the source and destination instances are compatible before any data is transferred. It checks version compatibility, available storage, network connectivity, and account configuration.
Go to the Instances page. In the top navigation bar, select the region of the destination RDS instance. Click the instance ID to open the instance details page.
In the left navigation pane, click Cloud Migration/DR Deployment, then click the Feasibility assessment tab.
In the Configure Scenario and Source Type step, set the scenario to Migrate To Cloud and the source to ApsaraDB RDS Instance, then click Next.
In the Configure Destination Instance step, click Next.
In the Configure Source Instance step, select all prerequisite checkboxes, then click Next.
In the Start Feasibility Assessment step, configure the source database parameters.
Parameter Description Migration Task Name Auto-generated. No change needed. Source VPC/DNS IP Endpoint of the source ApsaraDB for MyBase for PostgreSQL instance. See View or change the internal and public endpoints and port numbers of an instance. Port of Source Instance Port number of the source instance. See View or change the internal and public endpoints and port numbers of an instance. Username Privileged account of the source instance. See View a database account. Password Password of the privileged account. Click Create Feasibility Assessment Task.
The instance status changes to Maintaining Instance while the assessment runs.
After the assessment completes, check the status in the Cloud Migration list on the Feasibility Evaluation page:
Success — proceed to Step 2.
Failed — click View Report in the Actions column and resolve the issue based on the error message. For help interpreting the report, see Interpret a cloud migration evaluation report. After resolving the issue, click Re-assess to run the assessment again.

Step 2: Migrate to the cloud
The feasibility assessment status must be Successful before you can start the migration.
On the Migration to Cloud tab, click Create Cloud Migration Task.

In the dialog box, select the successful assessment task from the Associated Assessment Task list.
After you select an assessment task, the system automatically fills in Migration Source Type, Source IP/DNS, Source Port, and Username. No manual input is required.

Click Initiate Migration to Cloud. The system starts the migration task automatically.
ImportantThe instance status changes to Migrating Data. You can read from and write to the source ApsaraDB for MyBase for PostgreSQL database during migration. Do not perform data migration, instance restarts, or configuration changes on the source instance.
Perform the cutover.
In the cloud migration task list, click the link in the Cloud Migration Phase column to view progress.
When the migration phase reaches Incremental Synchronization, click Cutover in the Actions column to promote the destination ApsaraDB RDS for PostgreSQL instance to primary.
In the Switch To Cloud dialog box, set the source ApsaraDB for MyBase for PostgreSQL instance to read-only, or stop your application from writing to it.
To set the source instance to read-only:
Log on to the ApsaraDB for MyBase for PostgreSQL database and run the following query to check whether a superuser exists.
-- Returns 'superuser check ok' if no user-created superusers exist SELECT CASE WHEN(count(rolname)<= 3) THEN 'superuser check ok' ELSE 'exists superuser created by user' END AS result FROM pg_roles where rolsuper= 't' and rolname in ('aurora', 'replicator') or rolname like 'pg%' GROUP BY rolname limit 1;If a superuser exists, contact Alibaba Cloud engineers for assistance.
If no superuser exists, continue with the following steps.
Log on to the ApsaraDB for MyBase console.
Use the Editabal Parameter feature to set rds_force_trans_ro_non_sup to on.

Log on to the ApsaraDB for MyBase for PostgreSQL database again and run the following command to terminate all existing sessions.
-- Terminates all active sessions except system accounts and the current session SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename not in ('replicator', 'monitor', 'pgsql', 'aurora') AND pid != pg_backend_pid();Select all checkboxes, click Switch Now, and wait for the migration to complete.
Step 3: Connect your application
Method 1: Swap endpoints (recommended)
Change the endpoint of the source ApsaraDB for MyBase for PostgreSQL instance to a temporary value, then assign its original endpoint to the destination ApsaraDB RDS for PostgreSQL instance. Your application reconnects automatically without any code changes.
Example:
| Instance | Before | After |
|---|---|---|
| ApsaraDB for MyBase | pgm-aaa.pg.rds.aliyuncs.com | pgm-ccc.pg.rds.aliyuncs.com (temporary) |
| ApsaraDB RDS | pgm-bbb.pg.rds.aliyuncs.com | pgm-aaa.pg.rds.aliyuncs.com |
See Modify the endpoint of an ApsaraDB for MyBase for PostgreSQL instance and Change the endpoint of an ApsaraDB RDS for PostgreSQL instance.
Method 2: Update your application configuration
Get the endpoint of the destination ApsaraDB RDS for PostgreSQL instance and update the database connection string in your application. See View and change the endpoints and port numbers of an ApsaraDB RDS for PostgreSQL instance.