RayDB LogoRayDB

Migration guides

Migrating to RayDB from another PostgreSQL provider or self-hosted instance is straightforward with the right approach. This guide provides step-by-step instructions for different migration methods.

Choosing a Migration Method

RayDB supports multiple migration options depending on your current setup:

  • Logical Backup & Restore – Best for moving databases with minimal downtime.
  • Continuous Replication – Ideal for reducing downtime by syncing changes.
  • Dump & Load – A simple approach for smaller databases.

1. Migrating Using Logical Backup & Restore

This method uses pg_dump and pg_restore to migrate data.

Steps:

  1. Backup your database from the source PostgreSQL instance:
    pg_dump -Fc -h source_host -U source_user -d source_db -f backup.dump
  2. Create a new cluster in RayDB.
  3. Restore the backup to the new cluster:
    pg_restore -h raydb_host -U raydb_user -d target_db -1 backup.dump
  4. Verify the migration by checking table contents and running test queries.

2. Migrating Using Continuous Replication

For larger databases requiring minimal downtime, use PostgreSQL’s logical replication.

Steps:

  1. Enable logical replication on the source database:
    ALTER SYSTEM SET wal_level = logical;
    SELECT pg_reload_conf();
  2. Create a publication on the source instance:
    CREATE PUBLICATION my_pub FOR ALL TABLES;
  3. Create a subscription on RayDB:
    CREATE SUBSCRIPTION my_sub
    CONNECTION 'host=source_host user=source_user dbname=source_db'
    PUBLICATION my_pub;
  4. Monitor synchronization and cut over once replication is complete.

3. Migrating Using Dump & Load (Small Databases)

This method is suitable for small datasets that do not require advanced replication.

Steps:

  1. Export data to SQL format:
    pg_dump -h source_host -U source_user -d source_db -f backup.sql
  2. Create a new cluster in RayDB.
  3. Import data into RayDB:
    psql -h raydb_host -U raydb_user -d target_db -f backup.sql

Post-Migration Checklist

  • Verify data integrity by comparing row counts.
  • Update application connection strings to point to the new RayDB cluster.
  • Monitor performance and optimize queries post-migration.

For more details on configuring PostgreSQL, see Managing PostgreSQL Versions.

On this page