From 2e43b759a84d9600e26557a7b02234d4429c2e4c Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Thu, 15 Feb 2024 00:37:53 +0100 Subject: hbak: introduce btrfs grace period for incremental snapshot restoration --- hbak/src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'hbak/src') 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) -- cgit v1.2.3