Module rusqlite::backup [−][src]
Online SQLite backup API.
To create a Backup
, you must have two distinct Connection
s - 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)) }
Structs
Backup | A handle to an online backup. |
Progress | Struct specifying the progress of a backup. The percentage completion can
be calculated as |
Enums
StepResult | Possible successful results of calling |