ApsaraDB RDS for PostgreSQL supports geo-disaster recovery (DR) by continuously replicating data from a primary instance to a DR instance in a different region. If the primary instance fails, promote the DR instance to take over and keep your application online with minimal downtime.
Setup overview
-
Connect the two regions using Cloud Enterprise Network (CEN).
-
Run a feasibility assessment on the DR instance.
-
Create the DR deployment task to start replication.
-
(Optional) Configure Private DNS so your application can switch to the DR instance without changing its connection string.
This guide covers the single-account scenario where both instances belong to the same Alibaba Cloud account and reside in different regions. If the instances belong to different accounts, see Connect VPCs in different accounts.
Prerequisites
Before you begin, make sure you have:
-
A DR instance that meets all of the following requirements:
-
The same major PostgreSQL engine version as the source instance
-
A primary instance type — read-only instances cannot serve as DR instances
-
A pay-as-you-go or subscription billing method — serverless instances cannot serve as DR instances
-
An empty database with available storage greater than or equal to the data size of the source instance
-
-
A synchronization account created on the source instance. For details, see Prepare to create a DR instance
Step 1: Connect the two regions with CEN
Use Cloud Enterprise Network (CEN) to connect the virtual private clouds (VPCs) of the source instance and the DR instance across regions.
-
Log on to the CEN console.
-
On the Instances page, click Create CEN Instance.
-
In the Create CEN Instance dialog box, click the Create CEN Only tab. Configure the following parameters, then click OK.
You can also click Create Scenario-specific CEN (Recommended) and follow the prompts.
Parameter Description Name A name for the CEN instance Description A description for the CEN instance Resource group The resource group for the CEN instance. If left blank, the instance is added to the default resource group. For details, see What is Resource Management? Tag One or more tags. Tag key: up to 64 characters; cannot be blank, start with aliyunoracs:, or containhttp://orhttps://. Tag value: up to 128 characters; can be blank; cannot start withaliyunoracs:or containhttp://orhttps:// -
On the Instances page, click the ID of the CEN instance you just created.
-
On the Basic Information tab, click the
icon next to VPC to add the VPCs of both instances to the CEN instance.-
Click OK.
-
Click Create More Connections and repeat the above steps for the DR instance.
Parameter Description Instance type Select Virtual Private Cloud (VPC) Region The region where the source instance resides — for example, China (Beijing) Network instance The VPC ID of the source instance. View it on the Database Connection page of the source instance vSwitch The vSwitch ID of the source instance and at least one vSwitch in another zone, to support multi-zone DR. View it on the Database Connection page of the source instance 
-
-
Go to Basic Settings > Bandwidth Plans and click Purchase Bandwidth Plan (Subscription).
-
Configure the bandwidth plan, then click Buy Now and complete the payment.
ImportantThe area selection cannot be changed after purchase. For supported regions and areas, see Work with a bandwidth plan.
Parameter Description CEN ID The CEN instance for which you are purchasing a bandwidth plan. After payment, the plan is automatically associated with the CEN instance Area A One of the two areas to connect — for example, Mainland China Area B The other area to connect — for example, Mainland China Billing method The billing method for the bandwidth plan. Default: Pay-By-Bandwidth. For details, see Billing rules Bandwidth The bandwidth value in Mbit/s, based on your expected replication traffic Bandwidth plan name A name for the bandwidth plan Order time The subscription duration. Select Auto-renewal to renew automatically -
On the Basic Settings > Bandwidth Plans tab, click Allocate Bandwidth for Inter-region Communication.
-
On the Connection with Peer Network Instance page, configure the following parameters and click OK. After saving, the configured bandwidth plan and allocated bandwidth appear on the Basic Information tab.
Parameter Description Instance type Select Inter-region Connection Region The first region — for example, China (Beijing) Transit router Auto-populated based on the selected region Attachment name A name for the inter-region connection Peer region The second region — for example, China (Hangzhou) Transit router Auto-populated based on the peer region Bandwidth allocation mode How bandwidth is allocated. Allocate from Bandwidth Plan: uses the bandwidth plan purchased in the previous step. Pay-By-Data-Transfer: charges based on data transfer volume Bandwidth plan The bandwidth plan associated with the CEN instance Bandwidth The bandwidth for this inter-region connection, in Mbit/s Default line type Keep the default value Advanced settings Keep the defaults. Three features are enabled: Associate with Default Route Table of Transit Router (auto-associates the connection with default route tables for forwarding), Propagate System Routes to Default Route Table of Transit Router (establishes route learning), and Automatically Advertise Routes to Peer Region (propagates routes between transit router route tables across regions) 
-
Add the VPC CIDR block of the DR instance to an IP address whitelist of the source instance, so that the DR instance can connect to the source instance. For details, see Configure an IP address whitelist. View the VPC CIDR block on the Database Connection page of the source RDS instance. For example:
192.168.0.0/16.
Step 2: Run a feasibility assessment
Before creating the DR relationship, run a feasibility assessment to confirm that the DR instance is ready.
-
Go to the Instances page. In the top navigation bar, select the region where the DR instance resides, then click the instance ID.
-
In the left navigation pane, click Cloud Migration/DR Deployment, then click the Feasibility assessment tab.
-
Set Scenario to DR Construction and Source to ApsaraDB RDS Instance, then click Next.
-
Confirm the DR instance configuration, then click Next.
-
In the Configure Source Instance step, select all listed items and click Next.
-
In the Start Feasibility Assessment step, enter the source instance details:
Parameter Description DR Construction Task Name Auto-generated. No changes needed Region of Source RDS Instance The region where the source instance resides — for example, China (Beijing) Name of Source RDS Instance The ID of the source instance IP Address/Domain Name of Source Instance The internal endpoint of the source instance. View it on the Database Connection page Username The synchronization account created during prerequisites — for example, replicatoraccountPassword The password for the synchronization account -
Click Create Feasibility Assessment Task. The DR Construction section shows the assessment status:
-
Successful: proceed to Step 3.
-
Failed: click View Report in the Actions column to diagnose and resolve the issues. For common errors, see Analyze the feasibility assessment report of DR deployment.
The DR instance status changes to Maintaining Instance while the assessment runs.
-
Step 3: Create the DR deployment task
Complete this step only after the feasibility assessment status is Successful.
-
Go to the Instances page. Select the region where the DR instance resides, then click the instance ID.
-
In the left navigation pane, click Cloud Migration/DR Deployment, then click the DR Construction tab.
-
Click Create DR Relationship.
-
In the Create DR Relationship dialog box, select the successful feasibility assessment task.
-
Click Create DR Relationship to start the task. The DR instance status changes to Maintaining Instance while the task runs. Monitor progress in the task list on the DR Construction tab:
-
Click the value in the Construction Phase column to see the current phase.
-
When Incremental Data Synchronization appears in the Construction Phase column, the DR deployment task is complete.
-
Click View Logs in the Actions column to see detailed task logs.
-
-
(Optional) To verify replication is running, connect to the source instance and run:
TABLE pg_stat_replication;
Step 4: (Optional) Configure Private DNS for seamless failover
Private DNS lets you resolve an internal domain name to the source instance endpoint under normal conditions, then remap it to the DR instance during a failover — without changing your application's connection string. For details, see What is Private DNS?
Set up the DNS zone and record
-
Log on to the Alibaba Cloud DNS console.Cloud Enterprise Network console
-
In the left navigation pane, click Private DNS (PrivateZone).
-
On the Private DNS (PrivateZone) page, go to Built-in Authoritative Module > User Defined Zones.
-
Click Add New Zone. In the Add Built-in Authoritative Zone panel, configure:
-
Built-in Authoritative Zone: enter a zone name — for example,
pg_test_1106. -
Alibaba Cloud VPC (in Effective Scope of Zone): select the VPCs of both the source instance and the DR instance.
View the VPC for each instance on its Database Connection page.
-
-
Find the new zone and click Resource Records Settings in the Actions column.

-
Click Add Record. In the Add Record panel, configure:
-
Record type: select CNAME.
-
Hostname: enter the subdomain prefix. Enter
@to use the zone name itself as the domain with no prefix. > Note: Use different prefixes to set up subdomains for different services — for example,api.<domain>for API traffic. For details, see Configure a subdomain. -
Request line: select Default in most cases. To return different endpoints for different DNS sources, add additional request lines such as ISP or outbound DNS. For details, see Intelligent DNS resolution. > Important: Always add a record with Request Line set to Default to prevent resolution failures when no specific source matches.
-
Record value: add the internal endpoints of both instances as two separate record values. Set the source instance weight to
100and the DR instance weight to0.

-
-
In the Change Resource Record Confirmation message, confirm the settings and click OK.
Verify the DNS configuration
-
Log on to an Elastic Compute Service (ECS) instance in the same VPC as the source instance.
-
Run
ping <your-zone-name>to verify connectivity. The internal domain name resolves to the source instance endpoint.
-
(Optional) Connect to the database using the internal domain name. If the connection succeeds, the DNS configuration is working. For connection instructions, see Connect to an ApsaraDB RDS for PostgreSQL instance.
Fail over using DNS
If the source instance fails, remap the domain to the DR instance:
-
Update the DNS record: set the DR instance weight to
100and the source instance weight to0. For details, see Modify DNS records. -
Verify the updated resolution from an ECS instance in the same VPC: Run
ping <your-zone-name>to confirm the domain now resolves to the DR instance endpoint.
-
(Optional) Connect using the internal domain name to confirm the DR instance is serving traffic. For connection instructions, see Connect to an ApsaraDB RDS for PostgreSQL instance.
What's next
-
To create a DR instance, see Create an ApsaraDB RDS for PostgreSQL instance.
-
To troubleshoot a failed feasibility assessment, see Analyze the feasibility assessment report of DR deployment.