aboutsummaryrefslogtreecommitdiff
path: root/src/db/lmdb_adapter.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-03-14 17:24:53 +0100
committerAlex Auvolat <alex@adnab.me>2024-03-15 10:57:22 +0100
commit8dff278b7227007d8a2c2f6c6d6f76c0c5d7a1ac (patch)
tree6fa6fff6b64a1f5f4c74b72cce9ca30c971f5d55 /src/db/lmdb_adapter.rs
parenta80ce6ab5ad9834c3721eeb4f626d53c9a8bb1f4 (diff)
downloadgarage-8dff278b7227007d8a2c2f6c6d6f76c0c5d7a1ac.tar.gz
garage-8dff278b7227007d8a2c2f6c6d6f76c0c5d7a1ac.zip
[db-snapshot] Implement db snapshotting logic in garage_db
Diffstat (limited to 'src/db/lmdb_adapter.rs')
-rw-r--r--src/db/lmdb_adapter.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs
index 59fa132d..4b131aff 100644
--- a/src/db/lmdb_adapter.rs
+++ b/src/db/lmdb_adapter.rs
@@ -3,6 +3,7 @@ use core::ptr::NonNull;
use std::collections::HashMap;
use std::convert::TryInto;
+use std::path::PathBuf;
use std::sync::{Arc, RwLock};
use heed::types::ByteSlice;
@@ -102,6 +103,15 @@ impl IDb for LmdbDb {
Ok(ret2)
}
+ fn snapshot(&self, to: &PathBuf) -> Result<()> {
+ std::fs::create_dir_all(to)?;
+ let mut path = to.clone();
+ path.push("data.mdb");
+ self.db
+ .copy_to_path(path, heed::CompactionOption::Disabled)?;
+ Ok(())
+ }
+
// ----
fn get(&self, tree: usize, key: &[u8]) -> Result<Option<Value>> {