From 3528927ea6e60d358ea254870efb0eb138c3a74a Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Tue, 2 Oct 2018 17:22:57 +0200 Subject: [PATCH] btrbk: bugfix: do not keep latest common snapshot for "incremental no" There is no reason to keep the latest common source snapshot if "incremental no" is configured (see #252). --- ChangeLog | 2 ++ btrbk | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a21ac8..73fa708 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,8 @@ btrbk-0.27.0-dev * Bugfix: add "btrfs filesystem usage" backend mapping (close #222). * Bugfix: do not fail (exitcode=10) if targets are not accessible on "btrfs snapshot --preserve". + * Bugfix: if "incremental no" is configured on target, do not keep + latest common snapshot. * Enhance internal data structures: - Allow snapshot_dir to be a mountpoint. - Search complete target tree for correlated subvolumes. diff --git a/btrbk b/btrbk index 9606dd0..557c9cf 100755 --- a/btrbk +++ b/btrbk @@ -5990,17 +5990,19 @@ MAIN: next; } - # always preserve latest common snapshot/backup pair - foreach my $child (@snapshot_children) { - my @receive_targets = get_receive_targets($droot, $child, exact => 1); - if(scalar(@receive_targets)) { - DEBUG "Force preserve for latest common snapshot: $child->{PRINT}"; - $child->{node}{FORCE_PRESERVE} = 'preserve forced: latest common snapshot'; - foreach(@receive_targets) { - DEBUG "Force preserve for latest common target: $_->{PRINT}"; - $_->{node}{FORCE_PRESERVE} = 'preserve forced: latest common target'; + # preserve latest common snapshot/backup (for incremental targets) + if(config_key($droot, "incremental")) { + foreach my $child (@snapshot_children) { + my @receive_targets = get_receive_targets($droot, $child, exact => 1); + if(scalar(@receive_targets)) { + DEBUG "Force preserve for latest common snapshot: $child->{PRINT}"; + $child->{node}{FORCE_PRESERVE} = 'preserve forced: latest common snapshot'; + foreach(@receive_targets) { + DEBUG "Force preserve for latest common target: $_->{PRINT}"; + $_->{node}{FORCE_PRESERVE} = 'preserve forced: latest common target'; + } + last; } - last; } }