Backup files using official backup command?

Issue #275 new
Kevin Wojniak created an issue

The backup docs docs seem to indicate backups should require some type of lock on the database, and the official backup API/command accomplishes this.

Is direct reading of the file fully safe, or the best way? For example if there are writes still in the WAL file, it won't get those.

What if a download used the sqlite3 executable to make a backup to a temporary location, and then downloaded that backup? That would also allow for the Content-Type header to be sent with reliable information.

The command can be run like this:

sqlite3 my.db ".backup my.db.bak"

Comments (3)

  1. Christopher Kramer

    Hmmm.. we cannot rely on the sqlite3 executable to be present and executable through php. On most shared hosting providers, this won't be the case. We might get a lock on the DB, make a temporary copy, release the lock and download the copy.

  2. Kevin Wojniak reporter

    You could check if it's available by executing sqlite3 --version with version_compare to 3.6.11 or greater, and store that once in the session. Then if that's set, use that command, otherwise do it as it's done now.

  3. Log in to comment