[Feature Request] Use SQLite Online Backup API (sqlite3_backup) instead of raw file copy #200
Closed
Devlicious-DE
started this conversation in
Ideas
Replies: 2 comments 1 reply
|
Update: After reviewing the current source (SqliteDatabase.php), I can see the implementation already uses sqlite3 .backup (SQLite's Online Backup API) — exactly what I proposed. However, the README still lists "File copy" as the CLI tool for SQLite, which is inaccurate and may give users a false sense of the safety guarantees (or lack thereof). |
1 reply
|
Done and README.md updated thanks again @Devlicious-DE 🙏 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Current behavior
SQLite backups are currently performed by copying the database file directly over SFTP. This approach risks backing up a corrupt or inconsistent state if the database is being written to at the time of the copy — WAL files and in-flight transactions are not captured atomically.
Proposed behavior
SQLite provides a native Online Backup API (sqlite3_backup_*) which creates a consistent, point-in-time snapshot of the database regardless of concurrent writes. This is the same mechanism used by sqlite3 .backup and tools like Litestream. It works by opening the database through the SQLite library itself, not by copying the raw file.
Alternatively, executing sqlite3 /path/to/db .dump produces a transactionally consistent SQL dump — similar to how pg_dump works for PostgreSQL.
Why this matters
Self-hosted applications like Vaultwarden, Actual Budget, or TidyQuest use SQLite as their primary datastore and are often actively written to. A raw file copy is not a safe backup strategy for a live SQLite database.
Suggested implementation
Either ship sqlite3 CLI in the Docker image and use .backup or .dump, or use the backup API via a small Go/PHP wrapper that connects locally to the database file path over the SSH tunnel before copying.
All reactions