All Products
Search
Document Center

ApsaraDB RDS:Migrate data between ApsaraDB RDS for PostgreSQL instances across different accounts

Last Updated:Sep 23, 2025

The cloud migration feature of ApsaraDB RDS for PostgreSQL supports the migration of self-managed PostgreSQL databases from Alibaba Cloud ECS instances or data centers. This feature also supports data migration between ApsaraDB RDS for PostgreSQL instances that belong to different accounts. This topic describes how to perform a cross-account migration using the cloud migration feature.

Prerequisites

  • The following requirements are met:

    • The major engine versions of the source and destination RDS instances are the same. PostgreSQL 10 or later is supported.

    • The destination RDS instance is a primary RDS instance. Read-only RDS instances do not support cloud migration.

    • The destination RDS instance uses cloud disks.

    • The destination RDS instance is empty. The available storage of the destination RDS instance is greater than or equal to the size of the data in the source RDS instance.

    • The CIDR block of the virtual private cloud (VPC) to which the source RDS belongs is different from the CIDR block of the VPC to which the destination RDS instance belongs.

  • For a cross-account migration, you must grant cross-account permissions on network instances. For more information, see Cross-account network instance authorization.

Precautions

When you migrate data between ApsaraDB RDS for PostgreSQL instances across different accounts, you must use Cloud Enterprise Network (CEN) to enable service interconnection over an internal network. This operation incurs fees. For more information, see Billing overview.

Procedure

Note

This topic uses an example where an ApsaraDB RDS for PostgreSQL instance is migrated from Account A to Account B. The source instance is in Account A. The destination instance and the CEN instance are in Account B.

  1. In Account B, configure a CEN instance to enable service interconnection between the two ApsaraDB RDS for PostgreSQL instances in different accounts.

    1. Create a CEN instance.

      1. Log on to the CEN console.

      2. On the Instances page, click Create CEN Instance.

      3. In the Create CEN Instance dialog box, configure the following parameters and click OK.

        Parameter

        Description

        Name

        Enter a name for the CEN instance.

        The name must be 2 to 128 characters in length and can contain digits, hyphens (-), and underscores (_). The name must start with a letter.

        Description

        Enter a description for the CEN instance.

        The description must be 2 to 256 characters in length and cannot start with http:// or https://. You can also leave this parameter empty.

    2. Add VPCs to the CEN instance.

      1. On the Instances page in the CEN console, click the ID of the CEN instance that is created.

      2. On the Basic Information tab, click the 添加网络实例 icon to the right of the number that is displayed below VPC to create VPCs.VPC后的加好

      3. On the Connect Network Instance page, configure the network instance and click Create.

        Note

        You must add the VPCs of the source and destination instances separately. This requires you to perform the operation twice. The following table describes how to add the VPC of the source instance. The procedure for adding the VPC of the destination instance is similar, except that you must set the Region and Network Instance parameters to the region and VPC of the destination instance, and set Resource Ownership to Same Account.

        Parameter

        Description

        Instance Type

        The default value is Virtual Private Cloud (VPC).

        Region

        Select the region where the source instance resides.

        Transit Router

        By default, no transit router exists in the current region. The system automatically creates one. Select a primary and a secondary zone for the transit router.

        Resource Ownership

        Select Cross-account and enter the UID of the account to which the source instance belongs.

        Note

        You can click the user icon in the menu bar to view the UID of the account.

        Connection Name

        Custom.

        Network Instance

        Select the VPC instance that the source instance uses. You can view the VPC ID on the Database Connection page in the ApsaraDB RDS console.源实例VPC

        After you select the VPC, select the vSwitches that correspond to the primary and secondary zones configured for the transit router.

      After the VPCs are added, the result is shown in the following figure:跨账号路由

    3. (Optional) Purchase a cross-region bandwidth plan.

      Note

      You must perform this step if the ApsaraDB RDS for PostgreSQL instances in Account A and Account B are in different regions, for example, if the source instance is in China (Beijing) and the destination instance is in China (Hangzhou). If the instances are in the same region, skip this step and proceed to Step 2.

      1. On the Instances page in the CEN console, click the ID of the CEN instance that is created.

      2. On the Basic Information tab, click the Bandwidth Plans tab. On the tab that appears, click Purchase Bandwidth Plan (Subscription).

      3. On the page that appears, configure the following parameters and click Buy Now. Then, complete the payment.

        Parameter

        Description

        CEN ID

        Retain the CEN instance that is displayed. After you purchase a bandwidth plan, the bandwidth plan is automatically associated with the CEN instance.

        Area A

        Select an area for which you want to enable cross-region communication. In this example, select Mainland China.

        Note

        You cannot change the area after the bandwidth plan is purchased.

        Area B

        Select the other area for which you want to enable cross-region communication. In this example, select Mainland China.

        Billing Method

        Select a billing method for the bandwidth plan. Retain the default value Pay-By-Bandwidth.

        Bandwidth

        Specify the bandwidth that is provided by the bandwidth plan. Unit: Mbit/s.

        Bandwidth Package Name

        Enter a name for the bandwidth plan.

        Order time

        Select a subscription duration for the bandwidth plan.

        You can select Auto-renewal to enable auto-renewal for the bandwidth plan.

      After you complete the purchase, the result is shown in the following figure:跨账号带宽包

    4. (Optional) Set the cross-region bandwidth.

      Note

      You must perform this step if the ApsaraDB RDS for PostgreSQL instances in Account A and Account B are in different regions, for example, if the source instance is in China (Beijing) and the destination instance is in China (Hangzhou). If the instances are in the same region, skip this step and proceed to Step 2.

      1. On the Instances page in the CEN console, click the ID of the CEN instance that is created.

      2. On the Basic Information tab, click the Bandwidth Plans tab. On the tab that appears, click Allocate Bandwidth for Inter-region Communication.

      3. On the Connection with Peer Network Instance page, configure the following parameters and click OK.

        Parameter

        Description

        Instance Type

        In this example, select Inter-region Connection.

        Region

        Select the region in which the source RDS instance resides. In this example, select China (Beijing).

        Transit Router

        CEN automatically identifies the transit router in the region in which the source RDS instance resides.

        Peer Region

        Select the region in which the destination RDS instance resides. In this example, select China (Hangzhou).

        Transit Router

        CEN automatically identifies the transit router in the region in which the destination RDS instance resides.

        Bandwidth Allocation Mode

        Select an allocation method for the bandwidth plan. Valid values:

        • Allocate from Bandwidth Plan

        • Pay-By-Data-Transfer

        In this example, select Allocate from Bandwidth Plan.

        Bandwidth Plan

        Select a bandwidth plan that is associated with the CEN instance.

        Note

        This parameter is required only when you set Bandwidth Allocation Mode to Allocate from Bandwidth Plan.

        Bandwidth

        Enter the bandwidth that is provided by the bandwidth plan. Unit: Mbit/s.

        Default Line Type

        Select the type of line that you want to use. Valid values:

        • Platinum

        • Gold

        Note

        You can select Platinum only when you set Bandwidth Allocation Mode to Pay-By-Data-Transfer.

      After the configuration is successful, the result is shown in the following figure:跨账号设置带宽包

  2. Configure the source RDS instance.

    1. Create an IP address whitelist for the RDS instance.

      You must set the IP Addresses parameter to the CIDR block of the VPC to which the destination RDS instance belongs. For more information, see Configure an IP address whitelist.

      Method to obtain the VPC CIDR block

      1. Log on to the ApsaraDB RDS console and 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 instance ID.

      2. In the left-side navigation pane, click Database Connection. On the page that appears, check the Network Type parameter to obtain the VPC CIDR block. VPC网段

    2. Create a privileged account for the source RDS instance.

      For more information, see Create an account. When you create a privileged account, you must set the Account Type parameter to Privileged Account.

      Note

      The privileged account is used to migrate data and must have the CREATE ROLE, REPLICATION, and pg_monitor permissions. If you have a privileged account, skip this step.

  3. Configure the destination RDS instance.

    1. Perform a cloud migration assessment.

      1. Log on to the ApsaraDB RDS console and 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 instance ID.

      2. In the left-side navigation pane, click Cloud Migration/DR Construction. On the page that appears, click the Feasibility assessment tab.

      3. In the Configure Scenario and Source Type step of the configuration wizard, select Migration to Cloud for Scenario and ApsaraDB RDS Instance for Source. Then, click Next.

      4. In the Configure Destination Instance step of the configuration wizard, click Next.

      5. In the Configure Source Instance step of the configuration wizard, select all listed items and click Next. Before you start the cloud migration, you must complete the preparations that are described in the listed items.

      6. In the Start Feasibility Assessment step of the configuration wizard, configure the information about the source RDS instance.

        Parameter

        Description

        Migration Task Name

        ApsaraDB RDS automatically generates a name for the cloud migration task. You do not need to modify the generated name.

        Source VPC/DNS IP

        Enter the internal endpoint of the source RDS instance. For more information, see View and change the endpoints and port numbers.

        Port of Source Instance

        Enter the internal port number of the source RDS instance. For more information, see View and change the endpoints and port numbers.

        Username

        Enter the username of the privileged account that is created for the source RDS instance.

        Password

        Enter the password of the privileged account that is created for the source RDS instance.

      7. Click Create Feasibility Assessment Task.

        Note

        During the cloud migration assessment, the status of the destination RDS instance changes to Maintaining Instance.

        After the cloud migration assessment is complete, you can view the status of the cloud migration assessment task in Migration to Cloud section of the Feasibility assessment tab.

        • If the value in the Status column of the feasibility assessment task is Successful, you can start the cloud migration.

        • If the value in the Status column of the feasibility assessment task is Failed, you can click View Report in the Actions column to view and handle the reported errors. For more information about common errors, see Introduction to cloud migration assessment reports.

    2. Migrate data to the destination RDS instance.

      1. Log on to the ApsaraDB RDS console and 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 instance ID.

      2. In the left-side navigation pane, click Cloud Migration/DR Construction. On the page that appears, click the Migration to Cloud tab. On the tab that appears, click Create Cloud Migration Task.

      3. In the Create Cloud Migration Task dialog box, select the cloud migration assessment task whose status indicates a success from the Associated Assessment Task drop-down list.

        Note

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

      4. Click Initiate Migration to Cloud. ApsaraDB RDS automatically starts the cloud migration task.

        Important

        During the cloud migration, the status of the destination RDS instance changes to Migrating Data In. You can read data from and write data to the source RDS instance. However, do not migrate data from or to the source RDS instance, restart the source RDS instance, or change the specifications of the source RDS instance.

    3. Switch the workloads of the source RDS instance over to the destination RDS instance.

      1. Click the link in the Cloud Migration Phase column of the cloud migration task to view the task progress.

      2. When the cloud migration task enters the phase for incremental data synchronization, click the button for a switchover in the Actions column of the cloud migration task to switch the workloads of the source RDS instance to the destination RDS instance.

      3. In the Switchover dialog box, configure the source RDS instance to process only read requests. Alternatively, stop the connected application from writing data to the source RDS instance.

        Note

        To configure the source RDS instance to process only read requests, perform the following steps:

        1. Change the value of the rds_force_trans_ro_non_sup parameter of the RDS instance to on. For more information, see Modify the parameters of an ApsaraDB RDS for PostgreSQL instance.

        2. Execute the following statement 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 and click Switch Now. Then, wait until the cloud migration is complete.