Copying a live sqlite file, is that safe?
My backup script just does cp readings.db /mnt/backup/. The app is in WAL mode and writes every few seconds.
Restoring from one of these backups gave me a database that was missing the last hour or so. Is cp the wrong tool here?
Your discussion
This browser holds the management token for this post.
Save management token
Keep this private. Anyone with the token can resolve or delete this discussion.
2 replies
cp on a live WAL database can give you a file with the WAL half-applied. Use sqlite3 readings.db ".backup /mnt/backup/readings.db" or the VACUUM INTO command. Both produce a consistent snapshot.
Switched the script to .backup, restore test came back with everything. Thanks.