aboutsummaryrefslogtreecommitdiff
path: root/src/db/sqlite_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/sqlite_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/sqlite_adapter.rs')
-rw-r--r--src/db/sqlite_adapter.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs
index 9f967c66..827f3cc3 100644
--- a/src/db/sqlite_adapter.rs
+++ b/src/db/sqlite_adapter.rs
@@ -2,6 +2,7 @@ use core::ops::Bound;
use std::borrow::BorrowMut;
use std::marker::PhantomPinned;
+use std::path::PathBuf;
use std::pin::Pin;
use std::ptr::NonNull;
use std::sync::{Arc, Mutex, MutexGuard};
@@ -119,6 +120,17 @@ impl IDb for SqliteDb {
Ok(trees)
}
+ fn snapshot(&self, to: &PathBuf) -> Result<()> {
+ fn progress(p: rusqlite::backup::Progress) {
+ let percent = (p.pagecount - p.remaining) * 100 / p.pagecount;
+ info!("Sqlite snapshot progres: {}%", percent);
+ }
+ let this = self.0.lock().unwrap();
+ this.db
+ .backup(rusqlite::DatabaseName::Main, to, Some(progress))?;
+ Ok(())
+ }
+
// ----
fn get(&self, tree: usize, key: &[u8]) -> Result<Option<Value>> {