From 40d64c94959b966e4c36303c1c7e2df4fbf06a4d Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Fri, 16 Jan 2015 17:41:57 +0100 Subject: [PATCH] btrbk: do not clean subvolume if any target has previous errors --- btrbk | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/btrbk b/btrbk index 4efb39e..5369596 100755 --- a/btrbk +++ b/btrbk @@ -1242,9 +1242,13 @@ MAIN: next if($config_subvol->{ABORTED}); my $svol = $config_subvol->{svol} || die; my $snapdir = config_key($config_subvol, "snapshot_dir") || ""; + my $target_aborted = 0; foreach my $config_target (@{$config_subvol->{TARGET}}) { - next if($config_target->{ABORTED}); + if($config_target->{ABORTED}) { + $target_aborted = 1; + next; + } my $droot = $config_target->{droot} || die; # @@ -1272,6 +1276,7 @@ MAIN: } else { $config_target->{ABORTED} = "btrfs subvolume delete command failed"; + $target_aborted = 1; } $config_target->{schedule} = \@schedule; } @@ -1279,7 +1284,10 @@ MAIN: # # delete snapshots # - # TODO: don't delete any snapshots if on of the above failed + if($target_aborted) { + WARN "Skipping cleanup of snapshots for subvolume \"$sroot/$svol\", as at least one target aborted earlier"; + next; + } INFO "Cleaning snapshots: $sroot/$snapdir$svol.*"; my @schedule; foreach my $vol (keys %{$vol_info{$sroot}}) { @@ -1361,6 +1369,9 @@ MAIN: print "\nNOTE: Some errors occurred, which may result in missing backups!\n"; print "Please check warning and error messages above.\n"; } + if($dryrun) { + print "\nNOTE: Dryrun was active, none of the operations below were actually executed!\n"; + } } } }