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
Metadata
Release files for database-migration 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| database_migration-0.1.0.tar.gz | 28.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| database_migration-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.3 kB
Release files / database_migration-0.1.0.tar.gz
| Download URL | database_migration-0.1.0.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28b5aeeb530b8e656acb516d97f79e76c5a95a7b50b8d88d0162def7d7d79f0b
|
|
BLAKE2b-256 checksum How to use checksums |
5a95df81a10f02638f9ac4334904bb202c30e28638ce28ef3b712a4be78890ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / database_migration-0.1.0-py3-none-any.whl
| Download URL | database_migration-0.1.0-py3-none-any.whl |
|---|---|
| Size | 31.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0782078bedfc41c0ee23df51176c011eb774fdc2b155ef419f5b227e42ea4371
|
|
BLAKE2b-256 checksum How to use checksums |
66abbc0211ab9e6d128482b256f2214eaff9918d92df1aadaf37f8b11183aa57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|