Sqlite3_rsync : a remote copy tool for SQLite databases

Sqlite3_rsync : a remote copy tool for SQLite databases
2 min read

SQLite has a complementary tool, sqlite3_rsync, which allows copying a database to another machine without first creating a full copy on the local disk. According to Simon Willison’s blog, this feature, less well-known than the tool itself, remains one of the most useful.

First added as an “experimental” tool in SQLite 3.47.0 in October 2024, sqlite3_rsync was improved in SQLite 3.50.0 in May 2025. It is described in the official SQLite documentation.

A copy without additional disk space

To obtain a snapshot of a SQLite database, one usually has to use the backup API or the VACUUM INTO command. In both cases, sufficient disk space is required to create a duplicate of the database. On a small instance already using more than half its disk, this operation becomes impossible.

With sqlite3_rsync, a snapshot can be copied to another machine via an SSH connection, a secure remote link protocol, without going through a prior local copy.

The tool is also used to synchronize an existing copy without retransmitting the entire database over the network. Its operation is reminiscent of rsync, the classic file synchronization utility.

An exchange of fingerprints between two databases

The principle relies on cryptographic fingerprints, called hashes. The replica sends the source database the fingerprints of pages, i.e., data blocks of the database, or groups of pages. The source then returns the differing content, or requests finer-grained fingerprints when a fingerprint covering multiple pages does not match.

If the two databases are very different initially, the total volume of data exchanged can exceed the size of the entire database, due to the cost of exchanging fingerprints. This overhead, however, remains limited, at most a few percent.

Simon Willison notes that he had already written about this use of sqlite3_rsync in October 2024, at the time of the tool’s initial release.

S’abonner
Notification pour
guest

0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
0
Nous aimerions avoir votre avis, veuillez laisser un commentaire.x