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:Dec 03, 2025

This topic describes how to use the one-click cloud migration feature to migrate data from an ApsaraDB for MyBase for PostgreSQL instance to an ApsaraDB RDS for PostgreSQL instance.

Prerequisites

  1. Create an ApsaraDB RDS for PostgreSQL instance that meets the following requirements:

    • The Version and Series of the instance must be the same as the source ApsaraDB for MyBase for PostgreSQL instance.

    • The storage capacity must be larger than the used storage space of the source ApsaraDB for MyBase for PostgreSQL instance.

    • The instance family must be Dedicated Instance Types.

    For more information, see Create an ApsaraDB RDS for PostgreSQL instance.

    Note
  2. Configure whitelists to allow the ApsaraDB RDS for PostgreSQL and ApsaraDB for MyBase for PostgreSQL instances to access each other. For more information, see Configure a whitelist for an ApsaraDB RDS for PostgreSQL instance and Configure a whitelist for an ApsaraDB for MyBase for PostgreSQL instance.

    You can log on to the ApsaraDB RDS or ApsaraDB for MyBase console and view the CIDR block of the instance on the Database Connection page.查看网段

  3. Create a privileged account for the ApsaraDB for MyBase for PostgreSQL instance. For more information, see Create a database account.

Precautions

  • During the migration, you can read from and write to the source ApsaraDB for MyBase for PostgreSQL database. However, do not perform operations on the source instance, such as data migration, instance restarts, or configuration changes.

  • After you set the source ApsaraDB for MyBase for PostgreSQL instance to read-only, applications can no longer write data to it.

  • Instances of the General-purpose family do not support data migration over the internet.

Step 1: Perform a cloud migration evaluation

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

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

  3. In the Configure Scenario and Source Type step of the configuration wizard, set the scenario to Migrate To Cloud, the source to ApsaraDB RDS Instance, and click Next.

  4. In the Configure Destination Instancestep, click Next.

  5. In the Configure Source Instance step, select the check boxes for all the prerequisites that you have completed, and then click Next.

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

    Parameter

    Description

    Migration Task Name

    The system automatically generates a name. You do not need to change it.

    Source VPC/DNS IP

    The endpoint of the ApsaraDB for MyBase for PostgreSQL instance. For more information about how to view the internal and public endpoints of an instance, see View or change the internal and public endpoints and port numbers of an instance.

    Port of Source Instance

    The port number of the ApsaraDB for MyBase for PostgreSQL instance. For more information about how to view the port number of an instance, see View or change the internal and public endpoints and port numbers of an instance.

    Username

    The privileged account of the ApsaraDB for MyBase for PostgreSQL instance. For more information about how to view the instance account, see View a database account.

    Password

    The password of the privileged account for the ApsaraDB for MyBase for PostgreSQL instance.

  7. Click Create Feasibility Assessment Task.

    Note

    During the migration evaluation, the instance status changes to Maintaining Instance.

    After the evaluation is complete, you can view the status of the evaluation task in the Cloud Migration list on the Feasibility Evaluation page.

    After you resolve the issue, you can click Re-assess in the Actions column to run the evaluation task again.

    上云评估报告

Step 2: Migrate to the cloud

Note

You can start the cloud migration only when the status of the feasibility assessment task is Successful.

  1. On the Migration to Cloud tab, click Create Cloud Migration Task.

    创建迁移上云任务

  2. In the dialog box that appears, from the Associated Assessment Task list, select the successful evaluation task that you created in Step 1: Perform a cloud migration evaluation.

    迁移上云

    Note

    After you select a cloud migration assessment task from the Associated Assessment Task drop-down list, the system automatically obtains the values of the Migration Source Type, Source IP/DNS, Source Port, and Username parameters. You do not need to manually configure these parameters.

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

    Important

    During the cloud migration, the instance status changes to Migrating Data. You can read data from and write data to the ApsaraDB for MyBase for PostgreSQL database. However, do not perform operations on the source instance, such as data migration, instance restarts, or configuration changes.

  4. Perform the switchover.

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

    2. When the cloud migration phase is Incremental Synchronization, you can click Cutover in the Actions column to promote the ApsaraDB RDS for PostgreSQL instance to the primary database.

    3. In the Switch To Cloud dialog box, follow the prompts to set the source ApsaraDB for MyBase for PostgreSQL instance to read-only or stop your application from writing data to it.

      Note

      To set the ApsaraDB for MyBase for PostgreSQL instance to read-only:

      Log on to the ApsaraDB for MyBase for PostgreSQL database and execute the following command to check whether a superuser exists.

      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, perform the following steps to modify the settings:

        1. Log on to the ApsaraDB for MyBase console.

        2. Use the Editabal Parameter feature to set the rds_force_trans_ro_non_sup parameter to on.修改参数

        3. After the modification is complete, log on to the ApsaraDB for MyBase for PostgreSQL database and execute the following command to terminate all existing sessions.

          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 check boxes, click Switch Now, and then wait for the migration to complete.

Step 3: Connect your application

Method 1: Swap endpoints (Recommended)

Modify the endpoint of the source ApsaraDB for MyBase for PostgreSQL instance. Then, change the endpoint of the target ApsaraDB RDS for PostgreSQL instance to the original endpoint of the source ApsaraDB for MyBase for PostgreSQL instance.

For example, assume that the endpoint of your ApsaraDB for MyBase for PostgreSQL instance is pgm-aaa.pg.rds.aliyuncs.com and the endpoint of your ApsaraDB RDS for PostgreSQL instance is pgm-bbb.pg.rds.aliyuncs.com. You can change the endpoint of the ApsaraDB for MyBase for PostgreSQL instance to pgm-ccc.pg.rds.aliyuncs.com and then change the endpoint of the ApsaraDB RDS for PostgreSQL instance to pgm-aaa.pg.rds.aliyuncs.com.

Method 2: Change the application endpoint

Obtain the endpoint of the ApsaraDB RDS for PostgreSQL instance and modify the database endpoint in your application.