Module rusqlite::backup [] [src]

Online SQLite backup API.

To create a Backup, you must have two distinct Connections - one for the source (which can be used while the backup is running) and one for the destination (which cannot). A Backup handle exposes three methods: step will attempt to back up a specified number of pages, progress gets the current progress of the backup as of the last call to step, and run_to_completion will attempt to back up the entire source database, allowing you to specify how many pages are backed up at a time and how long the thread should sleep between chunks of pages.

The following example is equivalent to "Example 2: Online Backup of a Running Database" from SQLite's Online Backup API documentation.

fn backup_db<P: AsRef<Path>>(src: &Connection, dst: P, progress: fn(backup::Progress))
    -> Result<()> {
    let mut dst = try!(Connection::open(dst));
    let backup = try!(backup::Backup::new(src, &mut dst));
    backup.run_to_completion(5, time::Duration::from_millis(250), Some(progress))



A handle to an online backup.


Struct specifying the progress of a backup. The percentage completion can be calculated as (pagecount - remaining) / pagecount. The progress of a backup is as of the last call to step - if the source database is modified after a call to step, the progress value will become outdated and potentially incorrect.



Possible successful results of calling Backup::step.