Professional database cloning tool for PostgreSQL and MySQL
Project description
db-clone
Professional database cloning tool for PostgreSQL and MySQL.
Clone entire databases including schemas, tables, data, indexes, foreign keys, views, functions, triggers, and more — with streaming transfer for large databases, checkpoint/resume support, and Rich progress UI.
Installation
pip install db-clone
Quick Start
# Clone a PostgreSQL database
db-clone clone \
--source "postgresql://user:pass@source-host:5432/mydb" \
--target "postgresql://user:pass@target-host:5432/mydb_clone"
# Clone with options
db-clone clone \
--source "postgresql://user:pass@host/db" \
--target "postgresql://user:pass@host/db_clone" \
--strategy overwrite \
--batch-size 10000 \
--exclude-tables "temp_*,log_*"
# Resume an interrupted migration
db-clone clone --source "..." --target "..." --resume
# Schema only (no data)
db-clone clone --source "..." --target "..." --schema-only
# Data only (tables must exist)
db-clone clone --source "..." --target "..." --data-only
Commands
db-clone clone # Clone a database
db-clone info # Show database information
db-clone validate # Validate source matches target
db-clone checkpoint show # Show checkpoint state
db-clone checkpoint clear # Clear checkpoint
Features
- PostgreSQL → PostgreSQL and MySQL → MySQL cloning
- 11-phase ordered copy: schemas, extensions, types, sequences, tables, data, indexes, foreign keys, views, functions, triggers
- Streaming transfer: server-side cursors + batched inserts (no memory issues on large DBs)
- Checkpoint/resume: interrupt anytime with Ctrl+C, resume with
--resume - Conflict strategies:
overwrite(default),skip,fail - Table filtering:
--include-tablesand--exclude-tableswith glob patterns - Rich progress UI: live progress bars, summary tables
- Structured logging: file-based logs via structlog
Environment Variables
Instead of CLI options, you can use environment variables:
export DB_CLONE_SOURCE_URL="postgresql://user:pass@host:5432/db"
export DB_CLONE_TARGET_URL="postgresql://user:pass@host:5432/db_clone"
export DB_CLONE_BATCH_SIZE=5000
export DB_CLONE_LOG_LEVEL=INFO
Development
pip install -e ".[dev]"
pytest tests/unit/ -v
pytest tests/integration/ -v --run-integration # requires Docker
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file database_migration-0.1.0.tar.gz.
File metadata
- Download URL: database_migration-0.1.0.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28b5aeeb530b8e656acb516d97f79e76c5a95a7b50b8d88d0162def7d7d79f0b
|
|
| MD5 |
6a3aa3226c871693198df3e80cb1417b
|
|
| BLAKE2b-256 |
5a95df81a10f02638f9ac4334904bb202c30e28638ce28ef3b712a4be78890ec
|
File details
Details for the file database_migration-0.1.0-py3-none-any.whl.
File metadata
- Download URL: database_migration-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0782078bedfc41c0ee23df51176c011eb774fdc2b155ef419f5b227e42ea4371
|
|
| MD5 |
681e6e12d88a8131f1e747d205d22a1f
|
|
| BLAKE2b-256 |
66abbc0211ab9e6d128482b256f2214eaff9918d92df1aadaf37f8b11183aa57
|