All Products
Search
Document Center

ApsaraDB RDS:Migrate data from an ApsaraDB for MyBase for PostgreSQL instance to an ApsaraDB RDS for PostgreSQL instance

Last Updated:Mar 28, 2026

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:

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.

  1. 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.

  2. In the left navigation pane, click Cloud Migration/DR Deployment, then click the Feasibility assessment tab.

  3. 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.

  4. In the Configure Destination Instance step, click Next.

  5. In the Configure Source Instance step, select all prerequisite checkboxes, then click Next.

  6. In the Start Feasibility Assessment step, configure the source database parameters.

    ParameterDescription
    Migration Task NameAuto-generated. No change needed.
    Source VPC/DNS IPEndpoint 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 InstancePort number of the source instance. See View or change the internal and public endpoints and port numbers of an instance.
    UsernamePrivileged account of the source instance. See View a database account.
    PasswordPassword of the privileged account.
  7. 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.

Feasibility assessment report

Step 2: Migrate to the cloud

The feasibility assessment status must be Successful before you can start the migration.
  1. On the Migration to Cloud tab, click Create Cloud Migration Task.

    Create cloud migration task

  2. 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.

    Migration to cloud dialog

  3. Click Initiate Migration to Cloud. The system starts the migration task automatically.

    Important

    The 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.

  4. Perform the cutover.

    1. In the cloud migration task list, click the link in the Cloud Migration Phase column to view progress.

    2. When the migration phase reaches Incremental Synchronization, click Cutover in the Actions column to promote the destination ApsaraDB RDS for PostgreSQL instance to primary.

    3. 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.

      Modify parameter

      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();
    4. 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:

InstanceBeforeAfter
ApsaraDB for MyBasepgm-aaa.pg.rds.aliyuncs.compgm-ccc.pg.rds.aliyuncs.com (temporary)
ApsaraDB RDSpgm-bbb.pg.rds.aliyuncs.compgm-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.