aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBaptiste Jonglez <git@bitsofnetworks.org>2025-01-26 16:29:51 +0100
committerBaptiste Jonglez <git@bitsofnetworks.org>2025-01-27 19:06:52 +0100
commit43402c9619152e2d670f3b33fd09e3d3abf340e7 (patch)
tree359725a8c547f10cf5616d43b913c00ac6c0757e /src
parentefa6f3d85ee5a4db870aa429f57b946829af8552 (diff)
downloadgarage-43402c9619152e2d670f3b33fd09e3d3abf340e7.tar.gz
garage-43402c9619152e2d670f3b33fd09e3d3abf340e7.zip
snapshot: sqlite: use a subdirectory for consistency with LMDB
Currently, taking a snapshot of the metadata database with sqlite creates a sqlite file without extension with the following format: snapshots/2025-01-26T15:29:17Z This makes it hard to understand what kind of data this is, and is not consistent with LMDB: snapshots/2025-01-26T15:29:17Z/data.mdb With this change, we now get a directory with a single db.sqlite file: snapshots/2025-01-26T15:29:17Z/db.sqlite
Diffstat (limited to 'src')
-rw-r--r--src/db/sqlite_adapter.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs
index f3aa35d1..ce6412b6 100644
--- a/src/db/sqlite_adapter.rs
+++ b/src/db/sqlite_adapter.rs
@@ -144,9 +144,12 @@ impl IDb for SqliteDb {
let percent = (p.pagecount - p.remaining) * 100 / p.pagecount;
info!("Sqlite snapshot progress: {}%", percent);
}
+ std::fs::create_dir_all(to)?;
+ let mut path = to.clone();
+ path.push("db.sqlite");
self.db
.get()?
- .backup(rusqlite::DatabaseName::Main, to, Some(progress))?;
+ .backup(rusqlite::DatabaseName::Main, path, Some(progress))?;
Ok(())
}