Migrate from Azure Database for PostgreSQL to Xata
Learn how to migrate your Azure Database for PostgreSQL to Xata using xata clone. Step-by-step instructions for configuring the migration.
Prerequisites
- Azure Database for PostgreSQL instance
- Access to Azure Portal
- Xata account and project setup
- Network access to your Azure database
Install and Configure the Xata CLI
Install the Xata CLI:
curl -fsSL https://xata.io/install.sh | bash
Authenticate with your Xata account:
xata auth login
Network Configuration
Option 1: Public Access (Less Secure)
If your Azure database allows public access:
- Configure Firewall Rules:
- Go to "Networking" in the left menu
- Add your IP address to "Firewall rules"
- Or temporarily add
0.0.0.0/0
for migration (remove after)
Option 2: Private Access (Recommended)
For better security, use private endpoints:
-
Enable Private Endpoint:
- Go to "Networking" in the left menu
- Enable "Private endpoint connections"
- Configure VNet integration
-
Run Migration from Azure:
- Use Azure VM, App Service, or Azure Functions
- Ensure the service is in the same VNet as your database
Option 3: Azure Database for PostgreSQL Flexible Server
If you're using Flexible Server:
- Configure Network Access:
- Go to "Networking" in the left menu
- Choose "Private access (VNet Integration)" or "Public access"
- Configure firewall rules accordingly
Get Connection String
Azure connection strings typically look like this:
postgresql://your_username:your_password@your-server.postgres.database.azure.com:5432/postgres?sslmode=require
Initialize Xata Project
Set up your Xata project configuration:
xata init
Configure the Migration
Set up your clone configuration with optional anonymization:
# Set your source URL
export XATA_CLI_SOURCE_POSTGRES_URL="postgresql://your_username:your_password@your-server.postgres.database.azure.com:5432/postgres?sslmode=require"
# Configure anonymization rules
xata clone config --source-url $XATA_CLI_SOURCE_POSTGRES_URL --mode prompt
Start the Migration
Begin the data transfer:
# Start the migration
xata clone start --source-url $XATA_CLI_SOURCE_POSTGRES_URL
Monitor Progress
Check the migration status:
xata clone status
Verification
After migration, verify your data:
-
Connect to Xata Branch:
xata branch url
-
Check Data Integrity:
-- Compare row counts SELECT COUNT(*) FROM your_table; -- Check sample data SELECT * FROM your_table LIMIT 10;
-
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