3 ms·
Be careful! If you copy a database file while it is being modified, you may end up with an inconsistent view of the database depending on the order in which di
by cperciva 5y ago
Be careful! If you copy a database file while it is being modified, you may end up with an inconsistent view of the database depending on the order in which different parts of the file are modified.
There are ways around this (filesystem snapshots and potentially file locking) but it's not trivial and failing to handle this correctly is a very good way to build a system which passes tests under low load (when the file-copying operation will win all the relevant races) but fail catastrophically under heavy load.
- chasil 5y agoThe sqlite3 utility can be used to create a transaction-consistent backup of a live database. This interface is the only way that a backup should be taken, either from the utility or the C API. .backup ?DB? FILE Backup DB (default "main") to FILE https://sqlite.org/cli.html https://sqlite.org/cli.html