READ it.

sku-0412

smugglr reads sku-0412 from laptop/shop.db.

HASH it.

sku-0412 7d1c09ae ≠ 9a03b4f1

BLAKE3 of the word “hash” begins b6716efe. Every row is hashed the same way, and sku-0412 no longer matches the server.

SMUGGL it.

sku-0412 7d1c09ae, checked on the wire

Only that row crosses, and its hash is checked on the wire. The other seven match, so they stay put.

HASH it.

server: 9a03b4f1, unchanged

Before it writes, server/shop.db hashes its own copy: still the one it read.

WRITE it.

sku-0412 7d1c09ae = 7d1c09ae

It writes the row, reads it back, and the hashes match.

Then every row, both ways at once. Rows that match stay where they are; changed rows cross, each hash checked on the wire. A row changed on both sides stops and is named.

smugglr data is safe data.

READ it.

sku-0412

smugglr reads sku-0412 from laptop/shop.db.

HASH it.

sku-0412 7d1c09ae ≠ 9a03b4f1

BLAKE3 of the word “hash” begins b6716efe. Every row is hashed the same way, and sku-0412 no longer matches the server.

SMUGGL it.

sku-0412 7d1c09ae, checked on the wire

Only that row crosses, and its hash is checked on the wire. The other seven match, so they stay put.

HASH it.

server: 9a03b4f1, unchanged

Before it writes, server/shop.db hashes its own copy: still the one it read.

WRITE it.

sku-0412 7d1c09ae = 7d1c09ae

It writes the row, reads it back, and the hashes match.

Then every row, both ways at once. Rows that match stay where they are; changed rows cross, each hash checked on the wire. A row changed on both sides stops and is named.

smugglr data is safe data.

Install smugglr v0.6.4

On Linux and macOS, one line puts the binary in ~/.local/bin/smugglr, and says how to add that directory to PATH when it is not on it.

curl -fsSL https://smugglr.dev/install | bash

Or download v0.6.4

migratr

migratr changes the shape of a SQLite database; smugglr moves its rows. A migration is a JSON file, and a ledger table in the database records which have been applied.

plan prints the statements a run would execute and the snapshot each destructive step would take, and changes nothing. A destructive step takes its snapshot first, and restore puts the database back.

down reverses a migration only when every operation in it has an inverse.

A table rebuild uses no TEMP objects and leaves foreign keys on, so the same rebuild runs on a local file and on a D1 database.

migratr dev copies a remote database, the place, down and records a rewind point; up --smuggl and down --smuggl then ship a migration, or its revert, to the place through the smugglr binary (0.6.3 or later), and roll the local database back to the rewind point when a ship fails.

forgr on crates.io makes test data from the schema.json an app already has.

Install migratr v0.3.0

On Linux and macOS, one line puts the binary in ~/.local/bin/migratr, and adds that directory to PATH in your shell’s config when it is not on it.

curl -fsSL https://smugglr.dev/migratr/install | bash

Or download v0.3.0

» MACHINE-READABLE SUMMARY

GET /llms.txt

## 01 SCOPE

# one paragraph

smugglr keeps SQLite databases in step: a local file, any service that speaks HTTP-SQL, and Cloudflare D1. One Rust binary. Each row is compared by a 16-byte BLAKE3 hash of its contents, so only rows that changed cross the wire; a large first sync can move as a stash and a retrieve. A row changed in both places stops and is named; nothing is overwritten unless you say so. On a local network where nobody is in charge, smugglr mesh keeps nodes in step as changes happen. Every run prints a record, --json on request, and exits with a code that says what happened. smugglr sync <a> <b> --discover writes nothing and says what two places are and what a sync between them would meet. smugglr exec runs a migration's statements on a place for migratr. smugglr stash and smugglr retrieve, the multi shape, move a person's own devices through signed blobs.

## 02 INSTALL

# one binary, two ways

channelcommandwhat you get
Release archivehttps://github.com/rafters-studio/smugglr/releasessmugglr-<target>.tar.gz for four unix targets (x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin); smugglr-x86_64-pc-windows-msvc.zip for Windows
install.shcurl -fsSL https://smugglr.dev/install | bashThe latest release’s binary in ~/.local/bin/smugglr, on Linux and macOS, x86_64 or aarch64

## 03 PLACES

# one engine, every place

placeaddresscredentials
Local file./shop.dbnone
HTTP-SQL servicehttps://db.example.comnone sent
Cloudflare D1d1://shopCLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN

smugglr keeps no secrets and has no environment of its own; it reads the two D1 variables from the environment it runs in, set however you keep them: CLOUDFLARE_ACCOUNT_ID=<account-id> CLOUDFLARE_API_TOKEN=<token> smugglr sync ./shop.db d1://shop

## 04 EXIT CODES

# scripts branch on these

codemeaning
0Done, or a preview. Every row written was read back as written.
2Refused before anything was read or written: a bad flag, place or config, or a missing D1 variable.
3Stopped before writing anything, or --discover found a sync would stop.
4Wrote something and is not done. Run it again; a stopped table stops again until its rows are settled.
5Too much for the wire. Nothing was sent.

## 05 SYNC MODES

# when a row changed in both places

--sync-modewhat happens
stopDefault. The table stops and names the rows.
sourceThe source’s copy is kept; each overwritten row is named.
targetThe target’s copy is kept; each overwritten row is named.
lastThe copy whose steering column is further on is kept.

## 06 THE RECORD

# pasted from the release binary

The preview names what would move. The run, here as JSON, moves exactly that.

$ smugglr sync laptop/shop.db server/shop.db --dryrun
smugglr sync: preview
  products: would move, 1 to target, 1 to source, 1 deleted in target, 0 deleted in source, 0 overwritten in target, 0 overwritten in source
    deleted in target: sku-0233
$ smugglr sync laptop/shop.db server/shop.db --json
{
  "status": "done",
  "first_sync": false,
  "deletes_seen": true,
  "tables": {
    "products": {
      "status": "moved",
      "to_target": 1,
      "to_source": 1,
      "deleted_in_target": [
        "sku-0233"
      ],
      "deleted_in_source": [],
      "overwritten_in_target": [],
      "overwritten_in_source": []
    }
  },
  "ignored": []
}

## 07 MESH

# nobody in charge

smugglr mesh keeps every node on a local network that holds one key in step, as changes happen. Each change is signed, sealed and resent until each peer has decided it. A node is named by its machine; on a network with no broadcast, a peers setting names the others.

$ sqlite3 ./node.db "insert into notes values('n1','first note');"   # on puck
$ sqlite3 ./node.db "select * from notes"   # on rzr
n1|first note
# rzr, output so far
smugglr mesh: node rzr on UDP port 31402, key 90efbbd2a018fbfd
smugglr mesh: applied 1 change to notes from puck, key 90efbbd2a018fbfd

## 08 LIMITS

# said in the same breath

Direct and mesh syncs exist in 0.6.4: --sync-type hub and multi are refused as not built yet, and stash and retrieve are the multi shape as commands. smugglr sends no credentials to an HTTP-SQL place. A first sync cannot see deletes. A mesh node that restarts can be taken by the others for a second machine under its name (#684).