Expand description
One way to copy a SQLite database file: VACUUM INTO a temporary file
beside the destination, then rename it into place.
Used by every copy srv makes of a store: the copy-forward of a previous
version’s databases (migrations/carry_forward.rs), the pre-migration
snapshot (snapshot.rs) and the pre-migration backup
(migrations/runner.rs). A plain file copy of a database in WAL mode can
miss committed writes that are still only in its -wal file, and other
processes may hold the shared stores open while a copy is taken;
VACUUM INTO reads through SQLite, so the copy holds every committed
write. The source is opened read-only, so copying never writes to it.
Functions§
- copy_
database - A consistent copy of the SQLite database
srcatdst.dstis replaced if it exists; a failed copy leaves no partial file behind. - copy_
database_ excluding_ zones - A consistent copy of the SQLite database
srcatdstthat leaves out every row ofzone_tableswhosezoneidstarts withzone_prefix.