developits21 downloadsSync your Obsidian vault across devices through your own Cloudflare Worker, with three-way merges and conflict files.
Self-hosted, conflict-safe sync for your Obsidian vault.
Distributed Sync is an Obsidian plugin plus a Cloudflare Worker backend that keeps your vault synchronized across devices without handing your notes to a third-party sync service. Metadata lives in Cloudflare D1, file bytes live in R2 as SHA-256-addressed blobs, and every client talks to your Worker over HTTPS.
Status: v1.2.1. Self-hosted and actively hardened; listed in the community directory. Start with a disposable test vault and a staging Worker before trusting a primary vault.
Upgrading from v1.0.x? The plugin ID changed from
obsidian-distributed-synctodistributed-syncso it can be published in the community directory. Install v1.1.0 into the new folder and re-enter your server URL and device token. Vault content is unaffected; the old plugin folder can be removed after the new version connects.
| Goal | How it works |
|---|---|
| You own the server | The Worker, D1 database, and R2 bucket run in your own Cloudflare account. There is no vendor account, subscription, or shared backend. |
| Conflicts are preserved, not guessed | Non-overlapping Markdown edits merge automatically with a three-way Myers diff. Overlapping or binary edits become sibling conflict files attributed to the remote device; nothing is silently overwritten. |
| No lost updates | Every write carries X-Base-Rev and is checked against the current revision inside an atomic D1 batch. A stale client gets an explicit conflict instead of overwriting newer data. |
| Incremental, not full-vault uploads | Clients pull a seq-ordered delta feed and fetch only the blobs they do not already have. Downloads support HTTP byte ranges. |
| Serverless and cheap to run | Designed for Cloudflare Workers, D1, and R2; the free tiers are usually enough for a personal vault. |
GET /v1/file?rev=…), tombstones, and configurable retention (0–36,500 days).flowchart LR
A["Obsidian + plugin<br/>laptop"] <-->|"HTTPS · Bearer token · /v1"| W["Cloudflare Worker<br/>sync API"]
B["Obsidian + plugin<br/>phone / tablet"] <-->|"HTTPS · Bearer token · /v1"| W
W -->|"metadata · revisions · tokens"| D[("D1")]
W -->|"SHA-256 blobs"| R[("R2")]
| Component | Responsibility |
|---|---|
plugin/ |
Obsidian plugin (TypeScript). Indexes the vault, watches file events, reconciles, merges, and pushes. |
server/ |
Worker API (TypeScript). Authentication, path validation, revision checks, D1 transactions, R2 storage, retention. |
test/ |
Node regression suites plus a real local workerd/D1/R2 smoke test. |
scripts/ |
Deterministic release packaging for Obsidian and BRAT. |
GET /v1/changes?since=<seq> in pages. The feed is a latest-state delta, not an immutable event log.X-Base-Rev. The Worker checks the expected revision and publishes the new revision, metadata, and seq atomically in one D1 batch. Rejected attempts can leave harmless gaps in seq.Blobs are content-addressed: the R2 key is derived from the SHA-256 of the bytes, so identical content is stored once and never mutated in place.
Requirements: Node.js 24+, a Cloudflare account, and Wrangler (installed as a project dependency).
git clone https://github.com/Developits/Obsync.git
cd Obsync
npm ci --ignore-scripts
cd server
npx wrangler login
npx wrangler d1 create obsidian-sync-db
npx wrangler r2 bucket create obsidian-sync-blobs
Copy the returned D1 database_id into server/wrangler.jsonc. The repository ships with an ID from the author's account; replace it rather than assuming it points at your database.
# Apply the schema to the new database.
npx wrangler d1 execute obsidian-sync-db --remote --file=./schema.sql
# Set the one-time enrollment secret, then deploy.
npx wrangler secret put API_KEY
npx wrangler deploy
Do not run resource-creation or schema commands against an existing deployment without checking its resources and backups first.
The bootstrap secret is only needed for the first device; afterward, an authorized device can mint tokens for the others.
read -r -s -p 'Bootstrap secret: ' OBSYNC_BOOTSTRAP_KEY; printf '\n'
curl --fail-with-body -X POST 'https://YOUR-WORKER.workers.dev/v1/tokens' \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $OBSYNC_BOOTSTRAP_KEY" \
-d '{"name":"Laptop"}'
unset OBSYNC_BOOTSTRAP_KEY
The response contains a sensitive device token. Store it in the plugin settings; never commit it or paste it into an issue.
Download the assets from the latest release, then choose one option:
main.js and manifest.json into YOUR_VAULT/.obsidian/plugins/distributed-sync/ (substitute your configured folder if it isn't .obsidian). Releases contain only the files the plugin installer uses; ZIPs remain available locally via npm run package.Developits/Obsync.Enable Distributed Sync under Settings → Community plugins, then open its settings:
| Setting | What to enter |
|---|---|
| Server URL | Your deployed Worker URL, e.g. https://obsidian-sync-worker.example.workers.dev |
| Device token | The token from step 2 |
| Device name | A unique name such as Laptop or Pixel |
| Auto sync | On by default; syncs on file events and on the interval below |
| Sync interval | Seconds between background checks (minimum 5, default 30) |
| Excludes | .obsidian, .trash, .git by default |
| Local diagnostics | Bounded, local-only logs; export on demand |
To add another device, open the settings on an authorized device and click Generate token. The token is copied to your clipboard.
Test create, edit, rename, delete, offline edits, and attachment sync in both directions using a disposable vault. Keep an independent backup and use only one sync mechanism on the same files.
Run a real Worker with local D1 and R2 persistence:
# Terminal 1 — initialize and start the local Worker
npx wrangler d1 execute obsidian-sync-db --local --file server/schema.sql \
--config server/wrangler.jsonc --persist-to .local-sync-test
npx wrangler dev --local --ip 127.0.0.1 --port 8787 \
--config server/wrangler.jsonc --persist-to .local-sync-test \
--var API_KEY:qa-only-bootstrap-fixture
# Terminal 2 — exercise the real HTTP surface
node test/workerd-smoke.mjs
The smoke script refuses non-loopback targets and uses only disposable fixtures. The visible fixture key is not a production credential.
.obsidian, .trash, and .git are excluded, so settings, themes, and plugins are not synced.The full engineering boundaries and validation history are in KNOWN-LIMITATIONS.md, DIAGNOSTICS.md, and REPAIR-STATUS.md.
npm ci --ignore-scripts
npm run check # validate metadata, lint, and typecheck both subprojects
npm run build # build the plugin bundle
npm test # regression suites (Node test runner)
npm run package # build deterministic release ZIPs into dist/
CI runs lint, typecheck, build, the regression suites, dependency audits, packaging, and a release workflow on version tags. The suites cover concurrent mutations, offline edits, rename collisions, conflict preservation, index recovery, retention, authentication, protocol validation, and plugin lifecycle behavior. Mocked adapters do not prove native Obsidian or device correctness; those remain separate release gates.
See CONTRIBUTING.md for development, testing, privacy, and release guidelines.
MIT © 2026 ISLAM MD NAHIDUL