---
title: "Prepare an External Source for Migration"
description: "Turn on logical replication on Amazon RDS, Aurora or Google Cloud SQL before migrating a database to Managed PostgreSQL."
url: https://community.exoscale.com/product/dbaas/service-specific/postgresql/recipes/prepare-an-external-source/
product: "PostgreSQL"
section: product
last_updated: 2026-11-10
---
> For AI agents: the documentation index is at https://community.exoscale.com/llms.txt. Every page is available as markdown at `<page URL>index.md` or with `Accept: text/markdown`.

# Prepare an External Source for Migration

This guide is provided for informational purposes. Because it involves third party tooling we cannot guarantee things still work exactly as described here.

Turn on logical replication on a source database hosted by Amazon RDS, Amazon Aurora or Google Cloud SQL, so that the `replication` method of the Managed PostgreSQL migration can use it.

## What the Source Needs

The `replication` method of
[Migrate to Managed PostgreSQL](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/migrate-to-managed-postgresql/index.md)
uses PostgreSQL logical replication. On the source, it needs:

- `wal_level` set to `logical`.
- A migration user allowed to replicate and to manage replication slots.
- A free replication slot for each database you migrate.
- A network path from the Managed PostgreSQL service to the source. The address the service
  connects from is described in
  [Allow the target to reach the source](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/migrate-to-managed-postgresql/index.md#allow-the-target-to-reach-the-source).

A managed provider does not let you edit `postgresql.conf` or `pg_hba.conf`. Each one has its own
parameter for logical replication and its own grant for the migration user. The sections below
name them; the provider's documentation is the reference for the exact steps, which change over
time. For a server you run yourself, follow
[Prepare the source](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/migrate-to-managed-postgresql/index.md#prepare-the-source)
on the migration page.

When a database does not meet the requirements, the migration uses the `dump` method for it. Run
the migration pre-check described on the migration page to see which method each database will
get before you start.

## Amazon RDS for PostgreSQL

- Set the parameter `rds.logical_replication` to `1` in a custom DB parameter group attached to
  the instance, then reboot the instance so the change takes effect.
- Give the migration user the `rds_replication` role.
- Allow the address of the Managed PostgreSQL service in the security group of the instance.

Reference:
[Logical replication for Amazon RDS for PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.FeatureSupport.LogicalReplication.html).

## Amazon Aurora PostgreSQL

- Set `rds.logical_replication` to `1` in a custom DB **cluster** parameter group, then reboot the
  writer instance.
- Give the migration user the `rds_replication` role.
- Point the migration at the writer endpoint of the cluster.

Reference:
[Setting up logical replication for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Replication.Logical.Configure.html).

## Google Cloud SQL for PostgreSQL

- Set the database flag `cloudsql.logical_decoding` to `on`. The instance restarts.
- Give the migration user the `REPLICATION` attribute:

  ```sql
  ALTER USER MIGRATION_USER WITH REPLICATION;
  ```

- Add the address of the Managed PostgreSQL service to the **authorized networks** of the
  instance.

Reference:
[Configure logical replication and decoding in Cloud SQL](https://docs.cloud.google.com/sql/docs/postgres/replication/configure-logical-replication).

## Check the Source

These queries are standard PostgreSQL and work on every provider. Run them on the source,
connected as the migration user.

The WAL level, which must be `logical`:

```sql
SHOW wal_level;
```

The free replication slots, which must be at least the number of databases you migrate:

```sql
SELECT current_setting('max_replication_slots')::int - count(*) AS free_slots
FROM pg_replication_slots;
```

The replication attribute of the migration user, on Cloud SQL:

```sql
SELECT rolname, rolreplication FROM pg_roles WHERE rolname = 'MIGRATION_USER';
```

On RDS and Aurora, membership of `rds_replication`:

```sql
SELECT pg_has_role('MIGRATION_USER', 'rds_replication', 'member');
```

Parameters:

- `MIGRATION_USER`: the user you pass to `--pg-migration-username`.

Then run the migration pre-check and start the migration, as described in
[Migrate to Managed PostgreSQL](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/migrate-to-managed-postgresql/index.md).

> [!WARNING]
> A logical replication slot that nobody reads keeps WAL on the source until its disk is full.
> After you stop or abandon a migration, check on the source that its slots are gone, as shown in
> [Cut over and stop the migration](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/migrate-to-managed-postgresql/index.md#cut-over-and-stop-the-migration).

## Related Pages

- [Migrate to Managed PostgreSQL](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/migrate-to-managed-postgresql/index.md)
- [Set up logical replication](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/set-up-logical-replication/index.md)

