Replicate data with Fivetran
Learn how to replicate data from Neon with Fivetran
Enrollment Pause for Logical Replication Beta
We have temporarily paused new enrollments in our Logical Replication Beta program. This pause is aimed at evaluating the feature's performance and incorporating feedback from our early adopters. Please stay tuned for updates, and thank you for your interest. We plan to reopen enrollment again soon.
Neon's logical replication feature allows you to replicate data from your Neon Postgres database to external destinations.
Fivetran is an automated data movement platform that helps you centralize data from disparate sources, which you can then manage directly from your browser. Fivetran extracts your data and loads it into your data destination.
In this guide, you will learn how to define a Neon Postgres database as a data source in Fivetran so that you can replicate data to one or more of Fivetran's supported destinations.
Prerequisites
Enable logical replication in Neon
important
Enabling logical replication modifies the Postgres wal_level
configuration parameter, changing it from replica
to logical
for all databases in your Neon project. Once the wal_level
setting is changed to logical
, it cannot be reverted. Enabling logical replication also restarts all computes in your Neon project, meaning active connections will be temporarily dropped before automatically reconnecting.
To enable logical replication in Neon:
- Select your project in the Neon Console.
- On the Neon Dashboard, select Project settings.
- Select Beta.
- Click Enable to enable logical replication.
You can verify that logical replication is enabled by running the following query from the Neon SQL Editor:
Create a Postgres role for replication
We recommend using a dedicated Postgres role for replicating data. The role must have the REPLICATION
privilege. The default Postgres role created with your Neon project and roles created using the Neon Console, CLI, or API are granted membership in the neon_superuser role, which has the required REPLICATION
privilege.
Grant schema access to your Postgres role
If your replication role does not own the schemas and tables you are replicating from, make sure to grant access. Run these commands for each schema:
Granting SELECT ON ALL TABLES IN SCHEMA
instead of naming the specific tables avoids having to add privileges later if you add tables to your publication.
Create a publication
Create the Postgres publication. Include all tables you want to replicate as part of the publication:
The publication name is customizable. Refer to the Postgres docs if you need to add or remove tables from your publication.
Create a replication slot
Fivetran requires a dedicated replication slot. Only one source should be configured to use this replication slot.
Fivetran uses the pgoutput
plugin in Postgres for decoding WAL changes into a logical replication stream. To create a replication slot called fivetran_slot
that uses the pgoutput
plugin, run the following command on your database using your replication role:
The name assigned to the replication slot is fivetran_pgoutput_slot
. You will need to provide this name when you set up your Fivetran source.
important
To prevent storage bloat, Neon automatically removes inactive replication slots after a period of time if there are other active replication slots. If you have or intend on having more than one replication slot, please see Unused replication slots to learn more.
Create a Postgres source in Fivetran
-
Log in to your Fivetran account.
-
On the Select your datasource page, search for the PostgreSQL source and click Set up.
-
In your connector setup form, enter a value for Destination Schema Prefix. This prefix applies to each replicated schema and cannot be changed once your connector is created. In this example, we'll use
neon
as the prefix. -
Enter the connection details for your Neon database. You can get these details from your Neon connection string, which you'll find in the Connection Details widget on the Dashboard of your Neon project. For example, let's say this is your connection string:
From this string, the values in the Fivetran Create a source dialog would show as below. Your actual values will differ, with the exception of the port number.
- Host: ep-cool-darkness-123456.us-east-2.aws.neon.tech
- Port: 5432
- Username: alex
- Password: AbC123dEf
- Database Name: dbname
-
For Connection Method, select Logical replication of the WAL using the pgoutput plugin and enter values for the Replication Slot and Publication Name. You deifned these values earlier (
fivetran_pgoutput_slot
andfivetran_pub
, respectively). -
If you are using Neon's IP Allow feature to limit IP addresses that can connect to Neon, add Fivetran's IPs to your allowlist in Neon.
For instructions, see Configure IP Allow. You'll need to do this before you can validate your connection in the next step. If you are not using Neon's IP Allow feature, you can skip this step.
-
Click Save & Test. Fivetran tests and validates the connection to your database. Upon successful completion of the setup tests, you can sync your data using Fivetran.
During the test, Fivetran asks you to confirm the certificate chain by selecting the certificate to use as the trust anchor. Select the
CN=ISRG Root X1, 0=Internet Security Research Group, C=US
option. This certificate is valid unitl until 2035-06-04.When the connection test is completed, you should see an All connection tests passed! message in Fivetran, as shown below:
-
Click Continue.
-
On the Select Data to Sync page, review the connector schema and select any columns you want to block or hash.
-
Click Save & Continue.
-
On the How would you like to handle changes? page, specify how you would like to handle future schema changes. For this example, we'll select We will allow all new schemas, tables and columns. Choose the option that best fits your organization's requirements.
-
Click Continue. Your data is now ready to sync.
-
Click Start Initial Sync to enable syncing.
References
Need help?
Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more detail, see Getting Support.
Last updated on