| Crates.io | database-replicator |
| lib.rs | database-replicator |
| version | 7.2.2 |
| created_at | 2025-11-25 20:39:57.032657+00 |
| updated_at | 2026-01-06 00:56:32.375648+00 |
| description | Universal database-to-PostgreSQL replication CLI. Supports PostgreSQL, SQLite, MongoDB, and MySQL. |
| homepage | https://github.com/serenorg/database-replicator |
| repository | https://github.com/serenorg/database-replicator |
| max_upload_size | |
| id | 1950415 |
| size | 1,298,599 |
Replicate any database to PostgreSQL with zero downtime. Supports PostgreSQL, SQLite, MongoDB, and MySQL/MariaDB.
New to SerenAI? Sign up at console.serendb.com to get started with managed cloud replication.
SerenAI provides managed PostgreSQL databases optimized for AI workloads. When replicating to SerenDB targets, this tool can run your replication jobs on SerenAI's cloud infrastructure - no local resources required.
Benefits of SerenAI Cloud Execution:
With just your API key set, the tool will interactively guide you through selecting your target project and database:
export SEREN_API_KEY="your-api-key" # Get from console.serendb.com
database-replicator init \
--source "postgresql://user:pass@source:5432/db"
The tool will:
sync commandsIf you already have your connection string, you can provide it directly:
export SEREN_API_KEY="your-api-key"
database-replicator init \
--source "postgresql://user:pass@source:5432/db" \
--target "postgresql://user:pass@your-db.serendb.com:5432/db"
For local execution (non-SerenDB targets), use the --local flag. See Remote Execution for details.
database-replicator is a command-line tool that replicates databases from multiple sources to PostgreSQL (including Seren Cloud). It automatically detects your source database type and handles the replication accordingly:
wal_level=logical| Source Database | Replication Type | Continuous Sync | Remote Execution |
|---|---|---|---|
| PostgreSQL | Native replication | ✅ Auto-detects: logical replication or xmin-based sync | ✅ Yes |
| AWS RDS (PostgreSQL) | Native replication | ✅ Auto-fallback to xmin when wal_level isn't logical | ✅ Yes |
| SQLite | JSONB storage | ❌ One-time | ❌ Local only |
| MongoDB | JSONB storage | ✅ Periodic refresh (24hr default) | ✅ Yes |
| MySQL/MariaDB | JSONB storage | ✅ Periodic refresh (24hr default) | ✅ Yes |
PostgreSQL sync methods:
wal_level=logical): Sub-second latency, real-time delete detectionChoose your source database to get started:
Zero-downtime replication with continuous sync:
database-replicator init \
--source "postgresql://user:pass@source-host:5432/db" \
--target "postgresql://user:pass@target-host:5432/db"
Managed PostgreSQL instances on AWS RDS require the rds_replication role (or rds_superuser) plus a parameter group with rds.logical_replication=1. Once those prerequisites are met, run:
database-replicator init \
--source "postgresql://replicator@your-rds-instance.abc123.us-east-1.rds.amazonaws.com:5432/db" \
--target "postgresql://user:pass@target-host:5432/db"
The CLI will surface missing RDS privileges and suggest the AWS commands needed to grant rds_replication so reruns stay idempotent.
One-time replication to JSONB storage:
database-replicator init \
--source /path/to/database.db \
--target "postgresql://user:pass@host:5432/db"
One-time replication with periodic refresh support:
database-replicator init \
--source "mongodb://user:pass@host:27017/db" \
--target "postgresql://user:pass@host:5432/db"
One-time replication with periodic refresh support:
database-replicator init \
--source "mysql://user:pass@host:3306/db" \
--target "postgresql://user:pass@host:5432/db"
wal_level changes.pgpass files, never in command outputChoose whichever approach best fits your environment.
| OS | Architectures |
|---|---|
| Linux | x86_64, arm64 |
| macOS | Apple Silicon (arm64), Intel (x86_64) |
| Windows | x86_64 |
database-replicator.PATH:chmod +x database-replicator*
sudo mv database-replicator* /usr/local/bin/database-replicator
database-replicator --help
On Windows, run the .exe directly or place it in a directory referenced by the PATH environment variable.
Requires Rust 1.70 or later.
Install via crates.io:
cargo install database-replicator
database-replicator --help
Build from this repository:
git clone https://github.com/serenorg/database-replicator.git
cd database-replicator
cargo build --release
./target/release/database-replicator --help
This approach is useful if you want to pin to a specific commit, apply local patches, or build for custom targets.
You can pull the published Docker image from Docker Hub (palomachain/database-replicator) or build your own from the release assets.
Pull a prebuilt image:
docker pull palomachain/database-replicator:v6.0.5
docker tag palomachain/database-replicator:v6.0.5 palomachain/database-replicator:latest
Build from GitHub release assets:
# latest release asset
docker build -t palomachain/database-replicator:latest .
# specific version
docker build --build-arg VERSION=v6.0.5 -t palomachain/database-replicator:v6.0.5 .
Run the CLI inside the container (pass connection strings via arguments or environment variables):
docker run --rm -it palomachain/database-replicator:latest \
validate --source "postgresql://user:pass@source/db" \
--target "postgresql://user:pass@target/db"
Mount local config files if needed:
docker run --rm -it \
-v "$PWD:/work" \
palomachain/database-replicator:latest \
init --source "$(cat /work/source.txt)" --target "$(cat /work/target.txt)"
For comprehensive PostgreSQL replication documentation, see README-PostgreSQL.md.
PostgreSQL-to-PostgreSQL replication uses logical replication for zero-downtime replication:
Example:
# Validate prerequisites
database-replicator validate \
--source "postgresql://user:pass@source:5432/db" \
--target "postgresql://user:pass@target:5432/db"
# Initial snapshot
database-replicator init \
--source "postgresql://user:pass@source:5432/db" \
--target "postgresql://user:pass@target:5432/db"
# Continuous sync
database-replicator sync \
--source "postgresql://user:pass@source:5432/db" \
--target "postgresql://user:pass@target:5432/db"
See README-PostgreSQL.md for:
--sync-interval, --reconcile-interval, --once)--daemon, --stop, --daemon-status)By default, the init command uses SerenAI's managed cloud service to execute replication jobs. This means your replication runs on AWS infrastructure managed by SerenAI, with no AWS account or setup required on your part.
Important: Remote execution is restricted to SerenDB targets only. To replicate to other PostgreSQL databases (AWS RDS, Neon, Hetzner, self-hosted), use the --local flag to run on your own hardware.
When you run init without the --local flag, the tool:
Your database credentials are encrypted with AWS KMS and never logged or stored in plaintext.
Remote execution requires a SerenDB API key for authentication. The tool obtains the API key in one of two ways:
export SEREN_API_KEY="your-api-key-here"
./database-replicator init --source "..." --target "..."
If SEREN_API_KEY is not set, the tool will prompt you to enter your API key:
Remote execution requires a SerenDB API key for authentication.
You can generate an API key at:
https://console.serendb.com/api-keys
Enter your SerenDB API key: [input]
Getting Your API Key:
Security Note: Never commit API keys to version control. Use environment variables or secure credential management.
Remote execution is the default - just run init as normal:
# Runs on SerenDB's managed cloud infrastructure (default)
./database-replicator init \
--source "postgresql://user:pass@source-host:5432/db" \
--target "postgresql://user:pass@seren-host:5432/db"
The tool will:
Example output:
Submitting replication job...
✓ Job submitted
Job ID: 550e8400-e29b-41d4-a716-446655440000
Trace ID: 660e8400-e29b-41d4-a716-446655440000
Polling for status...
Status: provisioning EC2 instance...
Status: running (1/2): myapp
Status: running (2/2): analytics
✓ Replication completed successfully
To run replication on your local machine instead of SerenAI's cloud infrastructure, use the --local flag:
# Runs on your local machine
./database-replicator init \
--source "postgresql://user:pass@source-host:5432/db" \
--target "postgresql://user:pass@target-host:5432/db" \
--local
Local execution is required when:
# Override the default API endpoint if needed
export SEREN_REMOTE_API="https://your-custom-endpoint.example.com"
./database-replicator init \
--source "..." \
--target "..."
# Set 12-hour timeout for very large databases
./database-replicator init \
--source "..." \
--target "..." \
--job-timeout 43200
--local as a fallback--local to validate locally firstFor more details on the AWS infrastructure and architecture, see the AWS Setup Guide.
Contributions are welcome! Please feel free to submit a Pull Request.
Please report bugs and feature requests on the GitHub Issues page.
SerenAI is building infrastructure for AI agent data access. Agents are hungry for data and they will pay to access the data in your database. We're creating the layer that powers secure, compliant enterprise data commerce and data delivery for AI agents. SerenAI includes agent identity verification, persistent memory via SerenDB, data access control, tiered data-access pricing, SOC2-ready compliance systems, as well as micropayments and settlement.
Our team brings decades of experience building enterprise databases and security systems. We believe AI agents need to pay to access your data.
Get in touch: hello@serendb.com | serendb.com
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.