Skip to content

Provide API for reporting incremental database backup progress #1074

@mallman

Description

@mallman

The GRDB database backup API is implemented using SQLite's online backup API. At

https://github.com/groue/GRDB.swift/blob/v5.12.0/GRDB/Core/Database.swift#L1204

GRDB calls sqlite3_backup_step(backup, -1). According to the SQLite documentation, this will copy all remaining source pages. Since this is the only call into the sqlite3_backup_step function, GRDB performs the entire backup in one call. This simplifies the backup logic at the expense of opacity to the caller. Specifically, we do not know anything about the progress being made in the backup.

By providing a positive integer n to sqlite3_backup_step(backup, n), we can request an incremental database backup step copying up to n additional blocks. Additionally, SQLite provides the sqlite3_backup_remaining and sqlite3_backup_pagecount functions for calculating backup progress. The SQLite backup documentation provides an example of backing up a live database (Example 2: Online Backup of a Running Database) with a progress reporting callback. I believe we can use this example as a model for an implementation of a backup capability for GRDB that reports progress incrementally.

I will work on a PR for this issue. It shouldn't be too complicated. We'll see.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions