pub struct Maintenance { /* private fields */ }Expand description
Backup, restore, export and import operations.
Implementations§
Source§impl Maintenance
impl Maintenance
Sourcepub const fn supports_backup(&self) -> bool
pub const fn supports_backup(&self) -> bool
Whether file-level backup and restore are available.
False for PostgreSQL and externally-supplied databases — use
Self::export_to_file for those, or the backend’s own tooling
(pg_dump).
Sourcepub fn backup_to(&self, backup_path: impl AsRef<Path>) -> Result<BackupReport>
Available on crate feature sqlite only.
pub fn backup_to(&self, backup_path: impl AsRef<Path>) -> Result<BackupReport>
sqlite only.Take a consistent backup to backup_path, writing a sidecar manifest.
Safe to call while other threads are writing: the backup is taken with
VACUUM INTO inside a read transaction.
§Errors
Returns an error when the instance is not SQLite-backed, or when the backup or its checksum verification fails.
Sourcepub fn restore_from(
&self,
backup_path: impl AsRef<Path>,
target_path: impl AsRef<Path>,
options: &RestoreOptions,
) -> Result<RestoreReport>
Available on crate feature sqlite only.
pub fn restore_from( &self, backup_path: impl AsRef<Path>, target_path: impl AsRef<Path>, options: &RestoreOptions, ) -> Result<RestoreReport>
sqlite only.Restore a backup over target_path.
This does not affect the currently-open database handle: restore
writes a file, and the process must reopen crate::Commerce against
the restored path to see the new data. Restoring over the path this
instance currently has open is rejected, because the open connection
pool would keep serving pages from the replaced file.
§Errors
See stateset_db::maintenance::restore_from. Also errors when
target_path is the database this instance has open.
Sourcepub fn export_all<W: Write>(
&self,
writer: &mut W,
options: &ExportOptions,
) -> Result<ExportReport>
pub fn export_all<W: Write>( &self, writer: &mut W, options: &ExportOptions, ) -> Result<ExportReport>
Write a structured JSON export to writer.
§Errors
Returns an error if a repository read or the write fails.
Sourcepub fn export_to_file(&self, path: impl AsRef<Path>) -> Result<ExportReport>
pub fn export_to_file(&self, path: impl AsRef<Path>) -> Result<ExportReport>
Write a structured JSON export to path, creating parent directories.
§Errors
Returns an error if the file cannot be created or the export fails.
Sourcepub fn export_to_file_with(
&self,
path: impl AsRef<Path>,
options: &ExportOptions,
) -> Result<ExportReport>
pub fn export_to_file_with( &self, path: impl AsRef<Path>, options: &ExportOptions, ) -> Result<ExportReport>
Self::export_to_file with explicit options.
§Errors
Returns an error if the file cannot be created or the export fails.
Sourcepub fn import_all<R: Read>(
&self,
reader: &mut R,
options: &ImportOptions,
) -> Result<ImportReport>
pub fn import_all<R: Read>( &self, reader: &mut R, options: &ImportOptions, ) -> Result<ImportReport>
Read a structured JSON export from reader and replay it.
§Errors
Sourcepub fn import_from_file(
&self,
path: impl AsRef<Path>,
options: &ImportOptions,
) -> Result<ImportReport>
pub fn import_from_file( &self, path: impl AsRef<Path>, options: &ImportOptions, ) -> Result<ImportReport>
Read a structured JSON export from path and replay it.
§Errors
Returns an error if the file cannot be read or the import fails.
Sourcepub fn exportable_domains(&self) -> Vec<&'static str>
pub fn exportable_domains(&self) -> Vec<&'static str>
Domains the export covers, in export order.
Sourcepub fn importable_domains(&self) -> Vec<&'static str>
pub fn importable_domains(&self) -> Vec<&'static str>
Domains the import can write.