backup only.Expand description
Online SQLite backup API.
Alternatively, you can create a backup with a simple
VACUUM INTO <backup_path>.
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 = Connection::open(dst)?;
let backup = backup::Backup::new(src, &mut dst)?;
backup.run_to_completion(5, time::Duration::from_millis(250), Some(progress))
}Structs§
Enums§
- Step
Result - Possible successful results of calling
Backup::step.