3 ms·
> Do not use `cp` to back up SQLite databases. It is not transactionally safe. Anyone know if comitting the sqlite db file to git is not safe either?
by manjana 4y ago
> Do not use `cp` to back up SQLite databases. It is not transactionally safe.
Anyone know if comitting the sqlite db file to git is not safe either?
- Moto7451 4y agoIf you’re not actively writing to the database you can cp or commit it safely. SQLite uses a journal or a write ahead log (WAL) file to process transactions. If you cp a database mid transaction you will loose the transaction as it is processed in the separate journal or WAL file until commit. If you copy mid commit then you will have incomplete data in the main database file and possibly data corruption.
- benbjohnson 4y agoAnything that only uses the file system copying mechanics is not safe (which includes a git check-in). I wrote a more detailed comment here: https://news.ycombinator.com/item?id=31387447 https://news.ycombinator.com/item?id=31387447