Vibeleaderboard
← All Intel
Intel / article

sqlite3_rsync: Database Remote-Copy Tool For SQLite

Source
simonwillison.net
Date

Context

Simon Willison points out a practical use for `sqlite3_rsync`, a tool that comes with SQLite: copying a database to another machine when the holding it lacks the disk space to make a copy first (his post). The usual ways to take a consistent snapshot of a SQLite database, the backup API and `VACUUM INTO`, both write a full duplicate, so a database that already fills more than half of a small server's disk cannot be copied that way. `sqlite3_rsync` instead sends a snapshot over SSH to the other machine without first creating that local copy.

As its name suggests, the tool works like the familiar rsync -copying (SQLite documentation). The receiving copy sends cryptographic hashes of database pages or groups of pages, and the origin sends back only the pages that differ, so refreshing an existing replica does not resend the whole database. Other programs can keep writing to the origin and reading the replica while it runs, and the replica ends up as a consistent snapshot of the origin as it was when the command started. It has to be installed on both machines, at least one of the two databases must be local, and the replica is read-only during a sync. The tool arrived as experimental in SQLite 3.47.0 in October 2024, and 3.50.0 in May 2025 removed its original requirement that both databases use WAL mode and the same page size.

Key takeaways · AI-distilled
  • Snapshotting a SQLite database with the backup or VACUUM INTO needs enough free disk for a full duplicate, so a small instance already using more than half its disk cannot take a snapshot that way, Simon Willison notes.
  • sqlite3_rsync gets around that limit by copying a snapshot over SSH to another machine without first writing a full local copy.
  • Its protocol works like rsync: the replica sends cryptographic hashes of pages or page groups, and the origin returns only the pages that differ, or asks for finer-grained hashes when a multi-page hash does not match.
  • That makes it useful for keeping an existing replica in sync without resending the whole database. If the two copies start out very different, hash overhead can push total bandwidth past the database size, but by a few percent at most.
Terms in this piece · Glossary
  • Server — Software that receives requests, processes them and returns responses; the computer running it is its host.
  • API — Application programming interface: the agreed set of operations, inputs and outputs through which one piece of software uses another.
  • File — A named unit of stored data that keeps its contents while no program is using it.
  • Program — A set of instructions stored so that a computer can run it.

Get the Brief

A cited digest of what matters for people building with AI, every morning. Unsubscribe anytime. See today’s edition

Read the source simonwillison.net
Tools in this story
Recommended reads