Adds the Store.backup function to pyoxigraph

pull/190/head
Tpt 3 years ago
parent 0921a4e49c
commit 0d14159b6e
  1. 4
      lib/src/store.rs
  2. 27
      python/src/store.rs

@ -750,8 +750,8 @@ impl Store {
///
/// If you want to move your data to an other RDF storage system, you should have a look at the [`Store::dump_dataset`] function instead.
#[cfg(not(target_arch = "wasm32"))]
pub fn backup(&self, target_directory: &Path) -> Result<(), StorageError> {
self.storage.backup(target_directory)
pub fn backup(&self, target_directory: impl AsRef<Path>) -> Result<(), StorageError> {
self.storage.backup(target_directory.as_ref())
}
/// Loads a dataset file efficiently into the store.

@ -525,6 +525,33 @@ impl PyStore {
Ok(())
}
/// Creates database backup into the `target_directory`.
///
/// After its creation, the backup is usable using :py:class:`Store` constructor.
/// like a regular pyxigraph database and operates independently from the original database.
///
/// Warning: Backups are only possible for on-disk databases created by providing a path to :py:class:`Store` constructor.
/// Temporary in-memory databases created without path are not compatible with the backup system.
///
/// Warning: An error is raised if the ``target_directory`` already exists.
///
/// If the target directory is in the same file system as the current database,
/// the database content will not be fully copied
/// but hard links will be used to point to the original database immutable snapshots.
/// This allows cheap regular backups.
///
/// If you want to move your data to an other RDF storage system, you should have a look at the :py:func:`dump_dataset` function instead.
///
/// :param target_directory: the name of directory to save the database to.
/// :type target_directory: str
/// :raises IOError: if an I/O error happens during the backup.
#[pyo3(text_signature = "($self, target_directory)")]
fn backup(&self, target_directory: &str) -> PyResult<()> {
self.inner
.backup(target_directory)
.map_err(map_storage_error)
}
fn __str__(&self) -> String {
self.inner.to_string()
}

Loading…
Cancel
Save