Docs/Import/From PostgreSQL

Migrate from PostgreSQL

Use pg_dump and pg_restore to migrate your existing PostgreSQL database to PhoenixDB.

What you'll need:

  • Access to your source PostgreSQL database
  • pg_dump and pg_restore installed (comes with PostgreSQL)
  • A PhoenixDB database (create one first if you haven't)

1Export Your Source Database

Use pg_dump to create a backup of your source database:

pg_dump -Fc -v -h SOURCE_HOST -U SOURCE_USER -d SOURCE_DB > backup.dump
-Fc

Custom format (compressed, supports parallel restore)

-v

Verbose mode (shows progress)

2Import to PhoenixDB

Use pg_restore to import the backup to your PhoenixDB database:

pg_restore -v -h abc123.server1.phoenixdb.space -U postgres -d mydb backup.dump

You'll be prompted for your PhoenixDB database password.

Alternative: Direct Transfer

For smaller databases, you can pipe pg_dump directly to psql:

pg_dump -h SOURCE_HOST -U SOURCE_USER SOURCE_DB | \
  psql "postgresql://postgres:PASSWORD@abc123.server1.phoenixdb.space:5432/mydb?sslmode=require"

Schema-Only Migration

To migrate only the schema (no data):

pg_dump -Fc -v --schema-only -h SOURCE_HOST -U SOURCE_USER -d SOURCE_DB > schema.dump

Tips for Large Databases

Use Parallel Restore

For large databases, use the -j flag to run multiple jobs:

pg_restore -j 4 -v -d mydb backup.dump

Exclude Large Tables

Exclude specific tables that you don't need:

pg_dump --exclude-table=logs --exclude-table=sessions ...

Compress During Transfer

The -Fc (custom format) already compresses the dump file.

Version Compatibility

Make sure your source PostgreSQL version is compatible with your PhoenixDB version. pg_dump from a newer version may not work with an older database.