Appearance
Continuous mirroring
bash
pnpm mirror:git [target-directory]
NOTESFLOW_MIRROR_INTERVAL=10 pnpm mirror:git # seconds between checks
pnpm mirror:git --once # one pass, for a cron jobThe same writing as export:git, on a loop. It checks the workspace at an interval and commits when something has changed; the default is every 30 seconds.
The two commands share their writing deliberately. Two implementations would let a mirrored repository slowly diverge from an exported one, and the divergence would be invisible until somebody diffed them.
It is one-way, on purpose
Nothing here reads the repository. If somebody edits an exported file, the next export overwrites it.
That is the documented behaviour rather than a bug: this mirrors, it does not synchronise. When you do want external edits to come back, that is merge-back, and it is a separate command because it is a separate decision — one that can overwrite writing nobody has read yet.
Running it as a service
--once makes it a single pass, which is the right shape for cron or a systemd timer:
*/5 * * * * cd /srv/notesflow && pnpm mirror:git /srv/notes-mirror --onceThe loop form is better when you want the repository to be seconds behind rather than minutes, and it is a long-running process like any other — it needs the API reachable, and it will keep trying.
Worth knowing
- The mirror needs permission to read the whole workspace. A role holding
export_workspacecan read the fingerprint the mirror runs on; see roles and permissions. - A commit happens only when the tree actually changed, so the repository's history is a history of edits rather than a heartbeat.