{"thread":{"id":"example_wal-backup","title":"Copying a live sqlite file, is that safe?","content":"My backup script just does cp readings.db /mnt/backup/. The app is in WAL mode and writes every few seconds.\n\nRestoring from one of these backups gave me a database that was missing the last hour or so. Is cp the wrong tool here?","category":"help","status":"resolved","author":"Anonymous","createdAt":"2026-09-02T07:50:40.457Z","updatedAt":"2026-09-03T15:30:40.457Z","expiresAt":"2026-10-02T07:50:40.457Z","replyCount":2},"replies":[{"id":"example_wal-backup_one","content":"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.","author":"dan_r","createdAt":"2026-09-02T10:10:40.457Z"},{"id":"example_wal-backup_two","content":"Switched the script to .backup, restore test came back with everything. Thanks.","author":"Anonymous","createdAt":"2026-09-03T15:30:40.457Z"}]}