Skip to content

Portability and Rebuild

The markdown mirror, and rebuilding the database from it.

Updated View as Markdown

Every save writes to SQLite first

Inside a transaction — that commit is what makes the save real.

Then mirrors to a .md file

A plain markdown file with full YAML frontmatter, written next to the database.

Rebuild from it any time

npm run rebuild restores anything missing from the database, straight from the mirror.

SQLite is where Loggo actually reads and writes from, but it isn’t the only copy of your data. Every Log is also mirrored to disk as a plain .md file with full YAML frontmatter:

data/workspaces/personal-demo/2026/09/06/01JBX7Q2K9V3-postgres-tuning.md
data/workspaces/personal-demo/2026/09/06/_files/screenshot.png
---
id: 01JBX7Q2K9V3
title: Postgres tuning notes
day: 2026-09-06
created: 2026-09-06T10:12:00.000Z
updated: 2026-09-06T11:40:00.000Z
author: Demo
workspace: personal-demo
workspace_name: Personal
workspace_color: bg-blue-500
workspace_icon: gallery
tags: ["postgres","perf"]
pos_x: 24
pos_y: 24
---
Bumped `work_mem` and re-ran the slow query report. #postgres #perf

pos_x, pos_y, width, height, and z_index are only written when set — a log that’s never been dragged or resized on the canvas omits them.

Write ordering

A save commits to SQLite first, inside a transaction — that commit is what makes the save real. The .md file is written afterward, outside the transaction. If that write fails (a full disk, a storage outage), the Log is still saved, just flagged mirrorDirty for a background retry. A save should never fail because the filesystem is unhappy.

Dragging or resizing a card on the canvas skips the mirror write entirely — position, size, and z-index are pure UI arrangement, not content, so moving a card around never touches its file.

On the Cloudflare Workers demo the mirror is off; it’s a read-only environment anyway.

Rebuilding from the mirror

Because the frontmatter is complete — id, day, author, workspace, even workspace color/icon — the mirror directory is a real backup, not just a convenience copy. Running:

npm run rebuild

reads every .md file under the storage backend’s workspaces/ prefix and restores any log missing from the database: recreating users (as disabled placeholder accounts, since passwords aren’t in the mirror) and workspaces on demand from the frontmatter, and skipping any log ID that already exists. Point it at an empty database and a directory of .md files, and you get your data back.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close