Skip to main content

BackupManager

Struct BackupManager 

Source
pub struct BackupManager { /* private fields */ }
Expand description

Backup manager

Implementations§

Source§

impl BackupManager

Source

pub fn new(folder: &Path) -> Self

Create a new backup manager

Source

pub fn folder(&self) -> &Path

Get the backup folder path

Source

pub fn create_backup(&self, db: &Database, manual: bool) -> Result<PathBuf>

Create a backup

Requires a database reference to perform WAL checkpoint before backup.

Source

pub fn create_backup_from_path( &self, db_path: &Path, manual: bool, ) -> Result<PathBuf>

Create a backup from a raw database file path (DB must be closed)

Unlike create_backup, this does not perform a WAL checkpoint since the database is expected to be closed.

Source

pub fn restore_backup(&self, backup_path: &Path, db_path: &Path) -> Result<()>

Restore from a backup

Source

pub fn extract_backup( &self, backup_path: &Path, target_folder: &Path, ) -> Result<PathBuf>

Extract a backup to a folder (for inspection)

Source

pub fn list_backups(&self) -> Result<Vec<BackupInfo>>

List available backups

Source

pub fn verify_backup(&self, backup_path: &Path) -> Result<bool>

Verify a backup file

Source

pub fn cleanup_old_backups(&self, keep_count: usize) -> Result<usize>

Clean up old backups, keeping only the specified number

Source

pub fn get_latest_backup(&self) -> Result<Option<BackupInfo>>

Get the latest backup

Source

pub fn cleanup_auto_backups( &self, min_keep: usize, max_age_days: u32, ) -> Result<usize>

Clean up old automatic backups based on age

Only deletes automatic backups. Manual and imported backups are never touched. Keeps at least min_keep auto backups regardless of age. Deletes auto backups older than max_age_days only if enough newer ones exist. Returns the number of deleted backups.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V