Inside dbdr
Inside dbdr
How the program works, for people who want to change it: from a first dump to adding a backend, with real output from the example database.
Start Vol. IHacking dbdr
dbdr is one static Go binary. It works out what to create in what order, reads big tables in bounded pieces, and writes files you load back with one command.
Open source, BSD 3-Clause · 2 volumes · 20 chapters · 18,428 words
go install github.com/harishiyer89/dbdump/cmd/dbdr@latestor build from a checkout with make build, which puts the binary in
dist/. make build-all cross-compiles for macOS, Linux and Windows on
amd64 and arm64. How to use the tool, flag by flag, is covered in the
top-level README.
# Connections use TLS and verify the server's certificate by default;
# add --tls-ca for an internal CA, or --tls=disable for a local test server.
# ClickHouse: structure as SQL, data in the engine's own binary format
dbdr -db=shop -un=default --only=schema -o=schema.sql
dbdr -db=shop -un=default --only=data -fmt=native -o=data.zip
dbdr restore -un=default -hn=target -s=schema.sql -d=data.zip
# ClickHouse to Postgres: dump once, pick the destination at restore time
dbdr -db=shop -un=default --only=schema -fmt=portable -o=shop.dbschema
dbdr -db=shop -un=default --only=data -fmt=portable -o=shop.dbdata
dbdr restore -e=postgres -un=postgres -s=shop.dbschema -d=shop.dbdata| Format | What it is | Restorable into |
|---|---|---|
sql |
plain CREATE and INSERT text |
the same engine |
native |
the engine's own binary bulk format (ClickHouse Native, Postgres binary COPY), copied without decoding |
the same engine, fastest |
portable |
an engine-neutral JSON schema and a compact binary row format | any supported engine |
Which one to use, and when: Vol. II, chapter 1.
| Engine | Schema | SQL data | Native | Portable |
|---|---|---|---|---|
| ClickHouse | yes | yes | yes | yes |
| Postgres | yes | not yet | yes | yes |
| MySQL | registered stub only; see Chapter 9 |
Inside dbdr
How the program works, for people who want to change it: from a first dump to adding a backend, with real output from the example database.
Start Vol. I
dbdr in Production
For the people who run dbdr rather than change it: formats, least privilege, big tables, failures, proving a restore, and running unattended.
Start Vol. IIEach chapter ends with exercises. Some of them are a few minutes' work. Others are real features the program doesn't have yet, and a good answer to one of those would make a good pull request.
dbdr is short for database dump and restore.
This book and the dbdr source it describes are released under the BSD
3-Clause License. See LICENSE. Copyright (c) 2026, Littlebit
Labs.
Run it as you read.