diff options
author | Alex Auvolat <alex@adnab.me> | 2024-03-14 17:24:53 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2024-03-15 10:57:22 +0100 |
commit | 8dff278b7227007d8a2c2f6c6d6f76c0c5d7a1ac (patch) | |
tree | 6fa6fff6b64a1f5f4c74b72cce9ca30c971f5d55 /src/db/sled_adapter.rs | |
parent | a80ce6ab5ad9834c3721eeb4f626d53c9a8bb1f4 (diff) | |
download | garage-8dff278b7227007d8a2c2f6c6d6f76c0c5d7a1ac.tar.gz garage-8dff278b7227007d8a2c2f6c6d6f76c0c5d7a1ac.zip |
[db-snapshot] Implement db snapshotting logic in garage_db
Diffstat (limited to 'src/db/sled_adapter.rs')
-rw-r--r-- | src/db/sled_adapter.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/db/sled_adapter.rs b/src/db/sled_adapter.rs index 84f2001b..c34b4d81 100644 --- a/src/db/sled_adapter.rs +++ b/src/db/sled_adapter.rs @@ -2,6 +2,7 @@ use core::ops::Bound; use std::cell::Cell; use std::collections::HashMap; +use std::path::PathBuf; use std::sync::{Arc, RwLock}; use sled::transaction::{ @@ -96,6 +97,13 @@ impl IDb for SledDb { Ok(trees) } + fn snapshot(&self, to: &PathBuf) -> Result<()> { + let to_db = sled::open(to)?; + let export = self.db.export(); + to_db.import(export); + Ok(()) + } + // ---- fn get(&self, tree: usize, key: &[u8]) -> Result<Option<Value>> { |