Instead of using replication, you can move data from or to a Managed PostgreSQL cluster.
Prerequisites
- The external PostgreSQL cluster should be running version 10 or higher.
- The Managed PostgreSQL cluster must be able to connect to the external PostgreSQL cluster. Ensure that incoming connections are allowed for the external PostgreSQL cluster from the internet.
Configure the replication source
Set up the external PostgreSQL cluster:-
Enable logical replication by setting
wal_level = logicalinpostgresql.conffile. -
Create a user with replication privileges:
-
Create a publication for the tables you wish to replicate:
Configure the replication target
Set up the Managed PostgreSQL cluster:- In your Managed PostgreSQL cluster, create the table that will receive the replicated data. Ensure that the table schema matches the source table.
-
Establish a subscription to the external publication:
Upon successful creation, PostgreSQL will synchronize the data from the external source to the Managed PostgreSQL cluster.
-
Check that the data has been replicated correctly:
Monitoring and maintenance
-
Use the pg_stat_subscription view to monitor the status of your subscription:
- If you alter the schema of the replicated tables, ensure that corresponding changes are made on both the publisher and subscriber to prevent replication errors.
- Regularly monitor replication slots on the external PostgreSQL instance to prevent issues related to disk space, as logical replication slots retain WAL files until they are consumed by all subscribers.
Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.