parent
294cb99409
commit
e5e054187e
1 changed files with 21 additions and 2 deletions
|
@ -43,13 +43,32 @@ pub fn snapshot_metadata(garage: &Garage) -> Result<(), Error> {
|
|||
|
||||
let mut snapshots_dir = garage.config.metadata_dir.clone();
|
||||
snapshots_dir.push("snapshots");
|
||||
fs::create_dir_all(&snapshots_dir)?;
|
||||
if let Err(e) = fs::create_dir_all(&snapshots_dir) {
|
||||
drop(lock);
|
||||
error!(
|
||||
"Failed to create snapshots directory '{}': {}",
|
||||
snapshots_dir.display(),
|
||||
e
|
||||
);
|
||||
return Err(Error::Message(format!(
|
||||
"Failed to create snapshots directory '{}': {}",
|
||||
snapshots_dir.display(),
|
||||
e
|
||||
)));
|
||||
}
|
||||
|
||||
let mut new_path = snapshots_dir.clone();
|
||||
new_path.push(chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true));
|
||||
|
||||
info!("Snapshotting metadata db to {}", new_path.display());
|
||||
garage.db.snapshot(&new_path)?;
|
||||
if let Err(e) = garage.db.snapshot(&new_path) {
|
||||
drop(lock);
|
||||
error!("Failed to snapshot metadata db: {}", e);
|
||||
return Err(Error::Message(format!(
|
||||
"Failed to snapshot metadata db: {}",
|
||||
e
|
||||
)));
|
||||
}
|
||||
info!("Metadata db snapshot finished");
|
||||
|
||||
if let Err(e) = cleanup_snapshots(&snapshots_dir) {
|
||||
|
|
Loading…
Add table
Reference in a new issue