×
Community Blog pg_basebackup for ApsaraDB RDS for PostgreSQL Backups

pg_basebackup for ApsaraDB RDS for PostgreSQL Backups

The article explains how to use pg_basebackup to create full backups of an ApsaraDB RDS for PostgreSQL instance to an ECS server.

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.

Prerequisites

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

Procedure

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.

2

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

3

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

4

3.  View the backup file.

5

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

0 1 0
Share on

ApsaraDB

559 posts | 178 followers

You may also like

Comments

ApsaraDB

559 posts | 178 followers

Related Products