How Can I Change My Source From a Primary Database to a Replica Database Without Triggering a Historical Sync?
Question
How can I change my source from a primary to a replica database while avoiding a historical sync and associated resource costs?
Environment
All PostgreSQL connectors
Answer
To switch your source to a replica database without triggering a full historical sync, do the following:
- Ensure no new data is being written to your primary database.
- Manually trigger a sync in Fivetran until no more updates are detected.
- In Fivetran, go to your connector dashboard.
- In the top right, click SYNC NOW.
- Pause your connector.
- In the top right of your connector dashboard, set the ENABLED toggle to OFF.
- Ensure your replica database has a replication slot with the same name and configuration as your primary database. If you're unsure about its integrity or configuration, consider re-creating the replication slot on the replica.
- Configure your connector to point to the replica database.
- In your connector dashboard, select the Setup tab.
- Click Edit connection.
- In the Host field, enter your database host's IP.
- Enter your database instance's Port number. The port will be
5432
, unless you changed the default. - Enter the User and Password of the user with the necessary permissions on the replica database.
- Enter the name of your database.
- If you use the Logical Replication update method, enter the name of your database's Replication Slot and Publication Name. These are the same as your primary database.
- Execute the query
SELECT * FROM pg_replication_slots
on your replica database and note theconfirmed_flush_lsn
value returned. - Contact our support team to update the connector's cursor to the
confirmed_flush_lsn
value obtained in step 6. - In Fivetran, unpause your connector by setting the ENABLED toggle to ON.
NOTE: To minimize downtime, contact our support team 2 to 3 days before your migration. This will allow us to review the steps with you and ensure a support resource is available during the migration.