Simon Willison 介绍 SQLite 自 3.47.0 起提供的实验性工具 sqlite3_rsync,它可通过 SSH 远程复制数据库快照,无需在本地生成完整副本,并支持增量同步。
核心要点
sqlite3_rsync 是 SQLite 的附加工具,2024 年 10 月随 SQLite 3.47.0 以“实验性”身份加入,2025 年 5 月在 SQLite 3.50.0 中得到增强。
- 它可以通过 SSH 连接,把数据库快照复制到另一台机器,无需先在本地创建完整副本。
- 它适合同步已有副本,避免每次重新传输整个数据库。
- 工作方式类似常规 rsync:副本端发送页面或页面组的加密哈希,源端返回有差异的页面内容,或在多页哈希不匹配时请求更细粒度的哈希。
详细解读
通常获取 SQLite 数据库快照需要使用 backup API 或 VACUUM INTO,两者都要求有足够磁盘空间创建完整副本;如果小实例的磁盘占用已超过一半,就无法完成。sqlite3_rsync 绕开了这一限制,把快照直接经 SSH 传到远端。
在增量同步场景下,它只传输有差异的页面。若源端与副本端初始差异极大,交换哈希带来的额外带宽可能超过数据库本身大小,但超出幅度很小,最多几个百分点。
作者提到,他此前在 2024 年 10 月该工具首次发布时已写过这一用途,此次是重新认识到其“无需本地完整副本”这一吸引人的特性。
sqlite3_rsync: Database Remote-Copy Tool For SQLite
NewsletterSponsored by: Greptile — Review code faster with Greptile’s new PR inbox. It puts everything you need to understand a change and merge it on one screen.
Try it for free26th November 2026 - Link Blog
sqlite3_rsync: Database Remote-Copy Tool For SQLite. This additional SQLite tool has been around for a while now - it was added as "experimental" in SQLite 3.47.0 in October 2024 and enhanced in SQLite 3.50.0 in May 2025. It was only today that I understood one of its most attractive characteristics.
Normally, if you want to grab a snapshot copy of a SQLite database, you need to use either the backup API or VACUUM INTO. In both cases you need enough disk space to create a duplicate copy of your database, so if you're on a small instance and you already use more than half of the available disk you are plain out of luck.
sqlite3_rsync can copy a snapshot of your database over an SSH connection to another machine, without first needing to create a full local copy!
It's also good for synchronizing an existing copy of a database without re-transmitting the entire thing over the network. It works in a similar way to regular rsync:
The core idea behind the protocol is that the replica sends cryptographic hashes for pages or groups of pages over to the origin side. The origin sends back page content that differs, or requests finer-grain hashes if a multi-page hash does not match. If the origin and replica start out being vastly different, the total network bandwidth can exceed the size of the entire database, due to the overhead of exchanging hashes, but the excess bandwidth is not great - a few percent at most.
Update: Hah! Turns out I wrote about this application of sqlite_rsync back in October 2024 when the tool was first released.
Posted
26th November 2026 at 6:08 am
Recent articles
This is a link post by Simon Willison, posted on 26th November 2026.
backups 20 sqlite 885 Monthly briefing
Sponsor me for $10/month and get a curated email digest of the month's most important LLM developments.
Pay me to send you less!
Sponsor & subscribe