Lines Matching full:backup
1 //! Online SQLite backup API.
3 //! To create a [`Backup`], you must have two distinct [`Connection`]s - one
4 //! for the source (which can be used while the backup is running) and one for
5 //! the destination (which cannot). A [`Backup`] handle exposes three methods:
6 //! [`step`](Backup::step) will attempt to back up a specified number of pages,
7 //! [`progress`](Backup::progress) gets the current progress of the backup as of
8 //! the last call to [`step`](Backup::step), and
9 //! [`run_to_completion`](Backup::run_to_completion) will attempt to back up the
13 //! The following example is equivalent to "Example 2: Online Backup of a
14 //! Running Database" from [SQLite's Online Backup API
15 //! documentation](https://www.sqlite.org/backup.html).
18 //! # use rusqlite::{backup, Connection, Result};
25 //! progress: fn(backup::Progress),
28 //! let backup = backup::Backup::new(src, &mut dst)?;
29 //! backup.run_to_completion(5, time::Duration::from_millis(250), Some(progress))
51 /// until the backup completes.
53 /// For more fine-grained control over the backup process (e.g.,
54 /// to sleep periodically during the backup or to back up to an
55 /// already-open database connection), see the `backup` module.
60 /// or if the backup fails.
61 pub fn backup<P: AsRef<Path>>( in backup() method
69 let backup = Backup::new_with_names(self, name, &mut dst, DatabaseName::Main)?; in backup() localVariable
73 r = backup.step(100)?; in backup()
75 f(backup.progress()); in backup()
93 /// already-open database connection), see the `backup` module.
107 let restore = Backup::new_with_names(&src, DatabaseName::Main, self, name)?; in restore()
135 /// [`Backup::step`].
139 /// The backup is complete.
155 /// Struct specifying the progress of a backup. The
157 /// pagecount`. The progress of a backup is as of the last call to
158 /// [`step`](Backup::step) - if the source database is modified after a call to
159 /// [`step`](Backup::step), the progress value will become outdated and
169 /// A handle to an online backup.
170 pub struct Backup<'a, 'b> { struct
176 impl Backup<'_, '_> { argument
179 /// API calls on the destination of a backup while the backup is taking
187 pub fn new<'a, 'b>(from: &'a Connection, to: &'b mut Connection) -> Result<Backup<'a, 'b>> { in new()
188 Backup::new_with_names(from, DatabaseName::Main, to, DatabaseName::Main) in new()
194 /// the destination of a backup while the backup is taking place.
205 ) -> Result<Backup<'a, 'b>> { in new_with_names()
224 Ok(Backup { in new_with_names()
231 /// Gets the progress of the backup as of the last call to
232 /// [`step`](Backup::step).
248 /// [`run_to_completion`](Backup::run_to_completion) for a better
271 /// Attempts to run the entire backup. Will call
272 /// [`step(pages_per_step)`](Backup::step) as many times as necessary,
275 /// direct implementation of "Example 2: Online Backup of a Running
276 … /// Database" from [SQLite's Online Backup API documentation](https://www.sqlite.org/backup.html).
279 /// current progress of the backup. Note that is possible the progress may
281 /// backup is still running.
285 /// Will return `Err` if any of the calls to [`step`](Backup::step) return
310 impl Drop for Backup<'_, '_> { implementation
319 use super::Backup;
335 let backup = Backup::new(&src, &mut dst)?; in test_backup() localVariable
336 backup.step(-1)?; in test_backup()
345 let backup = Backup::new(&src, &mut dst)?; in test_backup() localVariable
346 backup.run_to_completion(5, Duration::from_millis(250), None)?; in test_backup()
366 let backup = in test_backup_temp() localVariable
367 Backup::new_with_names(&src, DatabaseName::Temp, &mut dst, DatabaseName::Main)?; in test_backup_temp()
368 backup.step(-1)?; in test_backup_temp()
377 let backup = in test_backup_temp() localVariable
378 Backup::new_with_names(&src, DatabaseName::Temp, &mut dst, DatabaseName::Main)?; in test_backup_temp()
379 backup.run_to_completion(5, Duration::from_millis(250), None)?; in test_backup_temp()
400 let backup = Backup::new_with_names( in test_backup_attached() localVariable
406 backup.step(-1)?; in test_backup_attached()
415 let backup = Backup::new_with_names( in test_backup_attached() localVariable
421 backup.run_to_completion(5, Duration::from_millis(250), None)?; in test_backup_attached()