Skip to main content

Graft

Git-like branching for Docker database volumes. Go Version License Graft brings Git-like branching to local Docker database volumes. Snapshot your database state into named branches and switch between them instantly — without SQL dumps, seed scripts, or manual volume management. Instead of exporting and importing SQL files, Graft operates on the database’s raw data files at the filesystem level. One command saves a state. One command switches to another state. The operation completes in seconds regardless of database size.

Key Features

  • Instant branching — Hardlink-based zero-copy branch creation via rsync --link-dest. Identical files across branches consume zero disk space.
  • Host filesystem storage — Branch data lives on your host under ~/.graft/. Browse it with Finder, ls, or any file manager. Back it up with cp -r.
  • Content-addressable storage — BLAKE3-hashed object pool with sharded layout. Every file is stored by its cryptographic hash — deduplication is automatic and perfect.
  • Merkle DAG integrity — Every commit produces a cryptographic fingerprint. Verify branch integrity on demand. Detect corruption at the file level.
  • Docker bind mount — After checkout, the container is recreated with a host bind mount pointing at the branch directory. No environment variable hacks.
  • Smart container lifecycle — Captures whether the container was running before an operation. Only restarts if it was originally running.

Quick Example

# Initialize on a running Postgres container
graft init my-postgres --bind

# Capture the current state
graft commit -m "seeded with test data"

# Create a branch and switch to it
graft checkout experiment

# Make changes in the database, then switch back
graft checkout main

Data Flow

graft init    →  Stop container → Bridge Docker volume to ~/.graft/
               →  Recreate with bind mount → Start container

graft commit  →  Stop container → Hash files → Store blobs in object pool
               →  Build Merkle tree → Insert commit in SQLite DAG → Start container

graft checkout →  Materialize tree from object pool into branch directory
               →  Recreate container with new bind mount → Start container

graft verify  →  Walk branch directory → Recompute Merkle root
               →  Compare against stored root → Report differences