READ it.
sku-0412smugglr reads sku-0412 from laptop/shop.db.
HASH it.
sku-0412 7d1c09ae ≠ 9a03b4f1BLAKE3 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 wireOnly that row crosses, and its hash is checked on the wire. The other seven match, so they stay put.
HASH it.
server: 9a03b4f1, unchangedBefore it writes, server/shop.db hashes its own copy: still the one it read.
WRITE it.
sku-0412 7d1c09ae = 7d1c09aeIt 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-0412smugglr reads sku-0412 from laptop/shop.db.
HASH it.
sku-0412 7d1c09ae ≠ 9a03b4f1BLAKE3 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 wireOnly that row crosses, and its hash is checked on the wire. The other seven match, so they stay put.
HASH it.
server: 9a03b4f1, unchangedBefore it writes, server/shop.db hashes its own copy: still the one it read.
WRITE it.
sku-0412 7d1c09ae = 7d1c09aeIt 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 | bashOr download v0.6.4
Each archive's SHA-256 is on the v0.6.4 release.
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 | bashOr download v0.3.0
Each archive's SHA-256 is on the v0.3.0 release.
» 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
| channel | command | what you get |
|---|---|---|
Release archive | https://github.com/rafters-studio/smugglr/releases | smugglr-<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.sh | curl -fsSL https://smugglr.dev/install | bash | The latest release’s binary in ~/.local/bin/smugglr, on Linux and macOS, x86_64 or aarch64 |
## 03 PLACES
# one engine, every place
| place | address | credentials |
|---|---|---|
Local file | ./shop.db | none |
HTTP-SQL service | https://db.example.com | none sent |
Cloudflare D1 | d1://shop | CLOUDFLARE_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
| code | meaning |
|---|---|
0 | Done, or a preview. Every row written was read back as written. |
2 | Refused before anything was read or written: a bad flag, place or config, or a missing D1 variable. |
3 | Stopped before writing anything, or --discover found a sync would stop. |
4 | Wrote something and is not done. Run it again; a stopped table stops again until its rows are settled. |
5 | Too much for the wire. Nothing was sent. |
## 05 SYNC MODES
# when a row changed in both places
| --sync-mode | what happens |
|---|---|
stop | Default. The table stops and names the rows. |
source | The source’s copy is kept; each overwritten row is named. |
target | The target’s copy is kept; each overwritten row is named. |
last | The 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).