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:
- Backup your database from the source PostgreSQL instance:
pg_dump -Fc -h source_host -U source_user -d source_db -f backup.dump - Create a new cluster in RayDB.
- Restore the backup to the new cluster:
pg_restore -h raydb_host -U raydb_user -d target_db -1 backup.dump - 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:
- Enable logical replication on the source database:
ALTER SYSTEM SET wal_level = logical; SELECT pg_reload_conf(); - Create a publication on the source instance:
CREATE PUBLICATION my_pub FOR ALL TABLES; - Create a subscription on RayDB:
CREATE SUBSCRIPTION my_sub CONNECTION 'host=source_host user=source_user dbname=source_db' PUBLICATION my_pub; - 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:
- Export data to SQL format:
pg_dump -h source_host -U source_user -d source_db -f backup.sql - Create a new cluster in RayDB.
- 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.