4 ms·
> Backup or restore while a transaction is active Is there any information whether taking a consistent snapshot (that contains both the DB file and journals)
by tgsovlerkhgsel 7y ago
> Backup or restore while a transaction is active
Is there any information whether taking a consistent snapshot (that contains both the DB file and journals) is safe?
- egdod 7y agoSeems like that would have the same problems if you do it while transactions are ongoing.
- tgsovlerkhgsel 7y agoGiven that the DB is designed to survive power outages (even during transactions), I don't really understand how that would be the case.
- dunham 7y agoI believe they are subtly different. If you copy while transactions are ongoing, you're reading different parts of a file at different points in time. For example, the beginning of the sqlite3 has already been copied, but by the time you get to the log file, blocks have been committed back into the beginning of the sqlite file. If you take a consistent snapshot of the filesystem first, I would think that would be the same as a crash in the middle of a transaction. Things should be in a consistent state that the recovery code at startup can handle.
- bob1029 7y agoIf you are using WAL, I feel volume-level snapshots are an acceptable approach.
- deleted 7y ago[deleted]
- pstuart 7y agoIt's recommended to use the backup api vs a filesystem copy: https://www.sqlite.org/backup.html https://www.sqlite.org/backup.html