Prerequisites
- Self-hosted PostgreSQL instance
- Access to PostgreSQL configuration files
- Xata account and project setup
- Network access to your PostgreSQL server
Install and Configure the Xata CLI
Install the Xata CLI:Network Configuration
Option 1: Public Access (Less Secure)
If your PostgreSQL server is accessible from the internet:-
Configure Firewall Rules:
- Allow PostgreSQL port (5432) from your IP address
- Or temporarily allow from anywhere (0.0.0.0/0) for migration
-
Update PostgreSQL Configuration:
- Edit
postgresql.conf
: Setlisten_addresses = '*'
- Edit
pg_hba.conf
: Addhost all all 0.0.0.0/0 md5
- Edit
Option 2: Private Network (Recommended)
For better security, use private network access:-
VPN or Private Network:
- Connect via VPN to your private network
- Use private IP addresses for connection
- Ensure your migration machine is in the same network
-
SSH Tunnel:
Option 3: Direct Server Access
If you have direct access to the server:- Run migration locally on the PostgreSQL server
- Install Xata CLI on the server
- Use localhost for connection
Get Connection String
Connection String Format
Self-hosted PostgreSQL connection strings typically look like this:SSL Configuration
If your PostgreSQL server requires SSL:Initialize Xata Project
Set up your Xata project configuration:Configure the Migration
Set up your clone configuration with optional anonymization:Start the Migration
Begin the data transfer:Monitor Progress
Check the migration status:Verification
After migration, verify your data:-
Connect to Xata Branch:
-
Check Data Integrity:
- Test Relationships: Verify foreign key relationships work correctly
Next Steps
- Explore Xata branching for development workflows
- Learn about schema changes with zero downtime
- Set up continuous sync for ongoing replication
- Consider deployment options for your Xata instance