pg_basebackup official website: https://www.postgresql.org/docs/current/app-pgbasebackup.html
This practical case demonstrates backing up an entire ApsaraDB RDS for PostgreSQL instance to an ECS instance and uses the Red Hat operating system and ApsaraDB RDS for PostgreSQL 17.
The pg_basebackup backup tool is installed on the ECS instance. The version of the tool is the same as that of the ApsaraDB RDS for PostgreSQL instance.
A privileged account or an account with the REPLICATION permission is created on the RDS instance.
Query the version of the pg_basebackup tool.

1. Log on to the ECS instance and check the pg_basebackup tool. Log on to the RDS instance to check whether the ECS instance can connect to the RDS instance.
View the endpoint of the ApsaraDB RDS for PostgreSQL instance.

Log on to the ApsaraDB RDS for PostgreSQL instance from the ECS instance. The following figure shows that the connection is successful.

2. Run the following command to back up the destination database.
pg_basebackup -Ft -Pv -Xs -z -D <backupdir> -Z5 -h '<hostname>' -p <port> -U <username> -W
Parameters
-D directory
Sets the target directory to write the output to. pg_basebackup will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty.
When the backup is in tar format, the target directory may be specified as - (dash), causing the tar file to be written to stdout.
This option is required.
Example:
pg_basebackup -Ft -Pv -Xs -z -D /data/pg_backup -Z5 -h pgm-gs55tg3921pdg04l.pgsql.singapore.rds.aliyuncs.com -p 5432 -U rambo -W

3. View the backup file.

If you need to use the backup file to restore the instance to the local database, see the documentation: https://www.postgresql.org/docs/current/continuous-archiving.html
digoal - April 30, 2021
Alibaba Clouder - November 14, 2017
digoal - January 30, 2022
Alibaba Clouder - February 24, 2020
Alibaba Clouder - August 2, 2019
Alibaba Clouder - February 25, 2021
PolarDB for PostgreSQL
Alibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn More
Database Backup
A reliable, cost-efficient backup service for continuous data protection.
Learn More
Database for FinTech Solution
Leverage cloud-native database solutions dedicated for FinTech.
Learn More
Oracle Database Migration Solution
Migrate your legacy Oracle databases to Alibaba Cloud to save on long-term costs and take advantage of improved scalability, reliability, robust security, high performance, and cloud-native features.
Learn MoreMore Posts by ApsaraDB