[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-115324":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":12,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":14,"stars7d":15,"stars30d":15,"stars90d":13,"forks30d":13,"starsTrendScore":16,"compositeScore":17,"rankGlobal":8,"rankLanguage":8,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":19,"topics":21,"createdAt":8,"pushedAt":22,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":13,"starSnapshotCount":13,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},115324,"db-branch","db-branch\u002Fdb-branch","Instant MySQL database branches on ZFS clones, clustered across VMs with ProxySQL routing",null,"Go",102,3,1,0,5,31,28,69.5,"Apache License 2.0",false,"main",[],"2026-11-23 17:38:18","2026-11-23 05:37:58","# db-branch\n\nInstant database branches for MySQL and PostgreSQL, on your own servers.\n\nTest a migration, let an AI agent loose, or give every pull request its own copy of the database. db-branch creates a copy-on-write branch of a large database in seconds, with nothing copied. Break it, reset it, throw it away. Built on ZFS clones, self-hosted, Apache-2.0.\n\n**Status: Beta.** db-branch is usable today, but APIs and command-line details may still change before 1.0. It is an independent open-source project, built from scratch.\n\n![Create a branch, drop a table, reset the branch, delete it](docs\u002Fassets\u002Fdemo.gif)\n\n## Try it\n\n1. **In your browser, 0 minutes.** A live console demo runs entirely in the page (nothing real is created): \u003Chttps:\u002F\u002Fdemo.db-branch.com\u002F>\n2. **On a Mac or Windows machine, about 2 minutes.** db-branch needs Linux and ZFS, so run it in an Ubuntu VM with [Multipass](https:\u002F\u002Fmultipass.run\u002F). One command makes the VM, installs db-branch, initialises it on a file-backed ZFS pool and loads a small sample base, `shop` (MySQL 8.4):\n\n   ```sh\n   multipass launch 24.04 --name db-branch-eval --memory 4G --disk 30G --timeout 900 \\\n     --cloud-init https:\u002F\u002Fraw.githubusercontent.com\u002Fdb-branch\u002Fdb-branch\u002Fmain\u002Fscripts\u002Feval-cloud-init.yaml\n   multipass exec db-branch-eval -- cloud-init status --wait    # wait for the setup (about two minutes)\n   multipass exec db-branch-eval -- cat \u002Fetc\u002Fmotd               # console URL and sign-in (admin \u002F admin), or what failed\n   multipass shell db-branch-eval                               # then: sudo db-branch branch create try --base shop --ttl 1h --record\n   ```\n\n   On Windows (PowerShell or cmd), put the `multipass launch` command on one line and drop the `\\`:\n\n   ```powershell\n   multipass launch 24.04 --name db-branch-eval --memory 4G --disk 30G --timeout 900 --cloud-init https:\u002F\u002Fraw.githubusercontent.com\u002Fdb-branch\u002Fdb-branch\u002Fmain\u002Fscripts\u002Feval-cloud-init.yaml\n   ```\n\n   - The history module is turned on, and the paid modules run for 30 days without a key. `--record` records a branch so it can be restored to any point.\n   - The pool is a file, so it is slower and not meant for real data. The first admin password is `admin`; the console asks for a new one at the first sign-in.\n   - On Apple Silicon (and other arm64 machines) the setup downloads about 800 MB for MySQL, against 80 MB on Intel, because Oracle ships no minimal build for arm64. `--timeout 900` keeps `launch` from giving up on a slow connection.\n   - If the setup fails, `\u002Fetc\u002Fmotd` says so, and `sudo tail -n 30 \u002Fvar\u002Flog\u002Fcloud-init-output.log` in the VM shows why.\n   - Delete the VM with `multipass delete --purge db-branch-eval`.\n3. **On your own Ubuntu server.** See [Install](#install).\n\n## Use cases\n\n- **AI agent sandboxes.** The built-in MCP server lets an LLM agent create a branch, run a risky query or migration on it, and delete the branch, so production data is never touched. For sensitive data, mask at the base snapshot stage rather than after branching (see [Design notes and trade-offs](#design-notes-and-trade-offs)).\n- **A database per pull request.** Each CI run or PR gets its own copy of a large database, ready in seconds, and removed by `--ttl` when it is no longer needed.\n- **Version-upgrade checks.** Run a major-version upgrade (for example MySQL 8.0 to 8.4) on one branch first, with `branch upgrade --check-only` to see what it would run into, before touching the base.\n\n## What it does\n\n- **Branches in seconds.** On our own 3-node test cluster a PostgreSQL branch is ready in about 0.5 s and a MySQL branch in about 3 s, with 0 bytes copied at creation (copy-on-write).\n- **Reset and expire.** `branch reset` returns a branch to its creation state; `--ttl` deletes it automatically.\n- **Checkpoints.** `branch checkpoint` saves a running branch's state instantly; `branch restore` puts it back. Restoring replaces the current state, and every checkpoint you already have stays restorable.\n- **Per-branch upgrades.** `branch upgrade` moves one branch to a newer MySQL or PostgreSQL version while the base and the other branches stay put. A checkpoint is saved first, and a failed upgrade rolls back by itself.\n- **MySQL and PostgreSQL, several versions at once.** Engine runtimes are installed by version and can live side by side.\n- **One interface everywhere.** CLI, REST API, web console and an MCP server (so LLM agents can create and query their own branches) all use the same API.\n- **Single node or cluster.** A Raft cluster of VMs, with optional ProxySQL routing so applications keep one address.\n\n## Web Console\n\n![The branches page of the web console](docs\u002Fassets\u002Fbranch-home.png)\n![The branch graph of the web console, showing which branch comes from which base](docs\u002Fassets\u002Fbranch-graph.png)\n\n## Install\n\nRequirements: Ubuntu 24.04 LTS or 26.04 LTS, and a ZFS pool (the `zfsutils-linux` package is installed as a dependency).\n\n```sh\ncurl -fsSL https:\u002F\u002Fapt.db-branch.com\u002Fdb-branch.gpg | sudo tee \u002Fusr\u002Fshare\u002Fkeyrings\u002Fdb-branch.gpg >\u002Fdev\u002Fnull\necho \"deb [signed-by=\u002Fusr\u002Fshare\u002Fkeyrings\u002Fdb-branch.gpg] https:\u002F\u002Fapt.db-branch.com stable main\" | sudo tee \u002Fetc\u002Fapt\u002Fsources.list.d\u002Fdb-branch.list\nsudo apt update && sudo apt install db-branch\nsudo db-branch init --pool \u003Czpool>\n```\n\nThe repository signing key fingerprint is `3F404C4E5D49FA653F8385692C6E89E341D4D7A5`. `db-branch init` prints the initial admin password once.\n\n## First branch\n\n```sh\ndb-branch runtime install postgres@18.6                                     # a database engine version\ndb-branch base create prod --runtime postgres@18.6 --dump prod.sql.gz       # a base: your data, loaded once\ndb-branch branch create feature-x --base prod --ttl 72h                     # a branch: instant, copy-on-write\ndb-branch branch dsn feature-x                                              # connection URL (includes the password)\ndb-branch branch checkpoint feature-x --name before-migration               # save the state (instant)\ndb-branch branch restore feature-x before-migration                         # go back to the saved state\ndb-branch branch reset feature-x                                            # discard every change\ndb-branch branch delete feature-x                                           # remove it\n```\n\nMySQL works the same way, for example `mysql@8.4.13`. List installable versions with `db-branch runtime available`. To try a version upgrade on one MySQL branch:\n\n```sh\ndb-branch branch upgrade feature-x --runtime mysql@8.4.13 --check-only      # what would the upgrade run into?\ndb-branch branch upgrade feature-x --runtime mysql@8.4.13                   # move this branch only; a checkpoint is saved first\n```\n\n## How it works\n\nA base is a ZFS dataset holding a loaded database. A branch is a ZFS clone of a base snapshot, so creating one copies nothing, and each branch runs its own database server on its own port. Optionally, ProxySQL routes client connections to the right branch by user name (or by a `\u002F*db_branch='name'*\u002F` query comment). Several nodes form a Raft cluster that shares bases, branches, settings and users.\n\n### Design notes and trade-offs\n\n- **Disposable by design (no merge or rebase).** Branches are block-level ZFS copy-on-write clones, not hooks into the database engine's MVCC. Divergent writes across concurrent branches cannot be merged or rebased back into a base or another branch like Git. db-branch is built for disposable sandboxes (AI agents, CI runs, migration tests) that you reset or throw away.\n- **Clean-shutdown vs. live snapshots.** Because PostgreSQL and MySQL (InnoDB) are crash-consistent, an atomic ZFS snapshot of a running instance (with data files and WAL\u002Fredo logs on the same volume) does work—and db-branch uses crash-consistent live snapshots for running-branch checkpoints. However, starting a branch from a live snapshot triggers crash recovery (WAL\u002Fredo log replay), which added about 10 s of startup latency in our MySQL testing. Base snapshots are therefore taken after a clean shutdown to keep branch creation sub-second \u002F a few seconds.\n- **Mask at the base, not after branching.** Branches isolate writes from production, but an AI agent or user with access to a branch can still *read* everything in it. If you load unmasked production data, sensitive records remain exposed to `SELECT` queries. Mask data when creating the base snapshot (using a masked dump or the `greenmask`, `greenmask-mysql`, or `anon` modules) rather than relying on post-branch masking.\n- **ZFS `recordsize` tuning.** ZFS's default `recordsize` (128K) does not match database page sizes, causing double copy-on-write \u002F `fsync` write amplification and hurting random I\u002FO. Matching `recordsize` to the engine's page size—`16K` for MySQL\u002FInnoDB and `8K` for PostgreSQL—avoids this overhead. (`db-branch` automatically sets `recordsize=16K` on base datasets, matching InnoDB; for PostgreSQL workloads sensitive to random I\u002FO, `8K` is the page-matched setting, trading some `lz4` compression efficiency.)\n\n## Editions\n\n- **Core (this repository), Apache-2.0:** branches, bases, runtimes, clustering, CLI, API, web console, MCP, monitoring, notifications, anonymous (no sign-in) branches with limits, scheduled base refresh, backup of cluster state.\n- **Free modules** in the same apt repository: `proxysql`, `greenmask`, `greenmask-mysql`, `anon` (routing and data masking).\n- **Paid modules** (auth\u002FSSO, audit, history, diff, FSx storage) are separate, closed-source packages, self-hosted and enabled with a license key (monthly or yearly). A governed masking workflow is planned as an opt-in beta and is not part of any plan yet. See [docs\u002Fmodules.md](docs\u002Fmodules.md) for the extension points they use.\n\nThere is no hosted or cloud version of db-branch.\n\n## Documentation\n\n- [docs\u002FREADME.md](docs\u002FREADME.md): index of the design and reference documents (written in Japanese)\n- English user documentation: \u003Chttps:\u002F\u002Fdb-branch.com\u002Fdocs\u002Fgetting-started\u002F>\n- Website: \u003Chttps:\u002F\u002Fdb-branch.com> (English), \u003Chttps:\u002F\u002Fdb-branch.com\u002Fja\u002F> (Japanese)\n- [api\u002Fopenapi.yaml](api\u002Fopenapi.yaml): machine-readable REST API definition\n- [CHANGELOG.md](CHANGELOG.md)\n\n## Contributing, security, support\n\n- Contributions are welcome: see [CONTRIBUTING.md](CONTRIBUTING.md). Commits need a DCO sign-off (`git commit -s`).\n- Security issues: see [SECURITY.md](SECURITY.md). Please use private vulnerability reporting, not public issues.\n- Support: see [SUPPORT.md](SUPPORT.md). No support is promised; Issues are read when possible.\n- Please follow the [Code of Conduct](CODE_OF_CONDUCT.md).\n\n## License\n\nApache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).\n\n## 日本語\n\ndb-branch は、ZFS クローンで MySQL \u002F PostgreSQL のデータベースブランチを発行・リセット・破棄するツールです。現在は Beta で、1.0 までに API が変わる可能性があります。コアは Apache-2.0 で、有償モジュール（認証\u002FSSO・監査・履歴・差分・FSx ストレージ）は別パッケージ（クローズドソース、セルフホスト、ライセンスキー）です。\n\nMac \u002F Windows では、Multipass のコマンド1つで試せます: \u003Chttps:\u002F\u002Fdb-branch.com\u002Fja\u002Fdocs\u002Fgetting-started\u002F#multipass-ですぐ試す>。日本語のサイトは \u003Chttps:\u002F\u002Fdb-branch.com\u002Fja\u002F>、設計ドキュメントは [docs\u002F](docs\u002F) にあります（日本語）。\n","db-branch 是一个用于在私有服务器上为 MySQL 和 PostgreSQL 数据库创建秒级、零拷贝分支的开源工具。它基于 ZFS 克隆实现写时复制（CoW），结合 ProxySQL 实现跨虚拟机集群的路由分发，支持按需创建、重置、回滚与销毁数据库分支。核心特点是低开销、强隔离、自托管，且内置历史记录与 MCP 接口，便于集成 AI 代理沙箱。适用于数据库迁移测试、CI\u002FCD 中每个 Pull Request 独立数据库环境、AI 驱动的 SQL 实验等需要高频、轻量、可丢弃数据库副本的场景。",2,"2026-11-24 04:50:41","CREATED_QUERY"]