>Do not use `cp` to back up SQLite databases. It is not transactionally safe.
I've read that this is true, but it has always confused me because I would expect that using cp would be equivalent to if the application had crashed / you lost power.
`cp` is not instantaneous. Unless you lock the entire file, one block can change while you're reading another block. You end up with a Frankenstein of a file, compared with a consistent snapshot if you had simply lost power.
If your filesystem supports snapshotting, it would be safe to create a snapshot and `cp` the database off of that snapshot.
No, because cp takes a non-zero amount of time and so by the time it has completed the first blocks may have been rewritten, thus the backup is inconsistent. If you take something like a ZFS snapshot, then, yes, that would be a consistent backup.
I've read that this is true, but it has always confused me because I would expect that using cp would be equivalent to if the application had crashed / you lost power.