aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2024-02-15 00:37:53 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2024-02-15 00:38:03 +0100
commit2e43b759a84d9600e26557a7b02234d4429c2e4c (patch)
tree5a634312d410d95912c99378af6e5c49450e5a1a
parentc3dc4f68afc63f7f3cf405cd6688139616a64afc (diff)
hbak: introduce btrfs grace period for incremental snapshot restoration
-rw-r--r--hbak/src/main.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/hbak/src/main.rs b/hbak/src/main.rs
index ce22b56..73c6b64 100644
--- a/hbak/src/main.rs
+++ b/hbak/src/main.rs
@@ -13,9 +13,15 @@ use std::fs::{self, File};
use std::io::{BufRead, BufReader, Empty};
use std::net::SocketAddr;
use std::sync::Mutex;
+use std::thread;
+use std::time::Duration;
use clap::{Parser, Subcommand};
+/// The grace period between btrfs invocations when restoring.
+/// Ensures that incremental snapshots that depend on each other become accessible in time.
+const BTRFS_GRACE_PERIOD: Duration = Duration::from_secs(2);
+
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
@@ -508,6 +514,7 @@ fn restore(
.ok_or(RemoteError::NotStreaming)?;
if child.wait().map_err(|_| RemoteError::RxError)?.success() {
+ thread::sleep(BTRFS_GRACE_PERIOD);
Ok(())
} else {
Err(RemoteError::RxError)