This topic describes how to use the pg_basebackup utility provided by open source PostgreSQL to create a full backup of your ApsaraDB RDS for PostgreSQL instance and export the backup files to your computer.
- The IP address of your ECS instance or local host is added to a whitelist of your RDS instance. For more information, see Configure a whitelist for an RDS PostgreSQL instance.
- Your ECS instance or local host runs the same version of PostgreSQL as your RDS instance.
In this topic, CentOS 7 and PostgreSQL 12 are used as examples of how to create a full backup.
We recommend that you use the privileged account of your RDS instance or an account that has the REPLICATION permission. Otherwise, you may have permission issues during creation.
- Log on to your ECS instance or local host. Then, run the following command to back
up a database from your RDS instance:
pg_basebackup -Ft -Pv -Xf -z -D <backupdir> -Z5 -h '<hostname>' -p <port> -U <username> -W
The following table describes parameters in this command. For more information, see pg_basebackup.
Parameter Description backupdir The directory of backup files that are exported. The system automatically creates this directory. However, if this directory already exists and is not empty, the system reports an error. hostname The endpoint that you use to connect to your RDS instance.
If your ECS and RDS instances are deployed in the same region under the same Alibaba Cloud account and have the same network type, we recommend that you use an internal endpoint. If both network types are VPC, the two instances must be in the same VPC.
Use a public endpoint in other scenarios.Note If you want to use a public endpoint to access your RDS instance, make sure that you have applied for the public endpoint. For more information, see Apply for or release a public endpoint.
port The port that you use to connect to your RDS instance. username A username of your RDS instance.
pg_basebackup -Ft -Pv -Xf -z -D /pg12/backup1/ -Z5 -h pgm-bpxxxxx.pg.rds.aliyuncs.com -p 1433 -U test1 -W
Password:appears, enter the password of the username of your RDS instance and press Enter.
If you want to use the backup files to restore data, see Recovering Using a Continuous Archive Backup.