Skip to main content

Module db_copy

Module db_copy 

Source
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 src at dst. dst is replaced if it exists; a failed copy leaves no partial file behind.
copy_database_excluding_zones
A consistent copy of the SQLite database src at dst that leaves out every row of zone_tables whose zoneid starts with zone_prefix.