From 8612804298d41a465f837bc6820c883306ac71e1 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 8 Jul 2022 15:31:12 +0100 Subject: [PATCH] Do short exclusions for remote backups (also bump version as protocol version incompatible) --- Cargo.lock | 4 ++-- datman/Cargo.toml | 4 ++-- datman/src/commands/ilabel.rs | 1 + datman/src/remote/backup_source_requester.rs | 10 ++++++++-- datman/src/remote/backup_source_responder.rs | 3 ++- yama/Cargo.toml | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83e8a91..e35a146 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,7 +404,7 @@ dependencies = [ [[package]] name = "datman" -version = "0.6.0-alpha.4" +version = "0.6.0-alpha.5" dependencies = [ "anyhow", "arc-interner", @@ -1733,7 +1733,7 @@ dependencies = [ [[package]] name = "yama" -version = "0.6.0-alpha.4" +version = "0.6.0-alpha.5" dependencies = [ "anyhow", "blake", diff --git a/datman/Cargo.toml b/datman/Cargo.toml index ba6f97e..ef308a7 100644 --- a/datman/Cargo.toml +++ b/datman/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "datman" -version = "0.6.0-alpha.4" +version = "0.6.0-alpha.5" authors = ["Olivier 'reivilibre' "] edition = "2021" repository = "https://bics.ga/reivilibre/yama" @@ -30,7 +30,7 @@ humansize = "1.1.1" chrono = "0.4.19" itertools = "0.10.1" hostname = "0.3.1" -yama = { path = "../yama", version = "0.6.0-alpha.1" } +yama = { path = "../yama", version = "0.6.0-alpha.5" } metrics = "0.17.1" bare-metrics-recorder = { version = "0.1.0" } comfy-table = "6.0.0-rc.1" diff --git a/datman/src/commands/ilabel.rs b/datman/src/commands/ilabel.rs index 21d507e..09b0c3d 100644 --- a/datman/src/commands/ilabel.rs +++ b/datman/src/commands/ilabel.rs @@ -213,6 +213,7 @@ pub fn interactive_labelling_session(path: &Path, source_name: String) -> anyhow &mut write, directory.as_ref(), !*cross_filesystems, + &BTreeSet::new(), )? .ok_or_else(|| anyhow!("Remote scan failed (does the directory exist?)"))? .replace_meta(&None); diff --git a/datman/src/remote/backup_source_requester.rs b/datman/src/remote/backup_source_requester.rs index a83f88c..4b810eb 100644 --- a/datman/src/remote/backup_source_requester.rs +++ b/datman/src/remote/backup_source_requester.rs @@ -5,8 +5,9 @@ use crate::tree::FileTree; use anyhow::{anyhow, bail}; use chrono::Utc; use log::info; +use std::collections::BTreeSet; use std::io::{Read, Write}; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::{Child, Command, Stdio}; use std::sync::Arc; use yama::commands::{load_pile_descriptor, open_pile}; @@ -49,11 +50,13 @@ pub fn scanning( write: &mut W, path: &Path, one_filesystem: bool, + exclusions: &BTreeSet, ) -> anyhow::Result>> { info!("Scanning."); write_message(write, &"scan")?; write_message(write, &path)?; write_message(write, &one_filesystem)?; + write_message(write, exclusions)?; write.flush()?; let scan_result: Option> = read_message(read)?; @@ -200,6 +203,9 @@ pub fn backup_remote_source_to_destination info!("Connecting..."); introduction(&mut read, &mut write)?; + let rules = load_labelling_rules(desc_path, source_name)?; + let exclusions = rules.get_exclusions_set(directory); + // then request to scan info!("Requesting scan... (this may take some time)"); let scan_result = scanning( @@ -207,10 +213,10 @@ pub fn backup_remote_source_to_destination &mut write, directory.as_ref(), !*cross_filesystems, + &exclusions, )? .ok_or_else(|| anyhow!("Remote scan failed (does the directory exist?)"))?; - let rules = load_labelling_rules(desc_path, source_name)?; let mut root = label_filter_and_convert(scan_result, descriptor, source_name, &rules, dest)? .ok_or_else(|| anyhow!("Empty filter..."))?; diff --git a/datman/src/remote/backup_source_responder.rs b/datman/src/remote/backup_source_responder.rs index 0966f62..9cda6f1 100644 --- a/datman/src/remote/backup_source_responder.rs +++ b/datman/src/remote/backup_source_responder.rs @@ -44,7 +44,8 @@ pub fn introduction(read: &mut R, write: &mut W) -> anyhow::R pub fn scanning(read: &mut R, write: &mut W) -> anyhow::Result<()> { let path: PathBuf = read_message(read)?; let one_filesystem: bool = read_message(read)?; - let scan_result = scan(&path, one_filesystem, &BTreeSet::new())?; + let exclusions: BTreeSet = read_message(read)?; + let scan_result = scan(&path, one_filesystem, &exclusions)?; write_message(write, &scan_result)?; write.flush()?; Ok(()) diff --git a/yama/Cargo.toml b/yama/Cargo.toml index b53a878..64ba592 100644 --- a/yama/Cargo.toml +++ b/yama/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yama" -version = "0.6.0-alpha.4" +version = "0.6.0-alpha.5" authors = ["Olivier 'reivilibre' "] edition = "2018" description = "Deduplicated, compressed and encrypted content pile manager"