btrbk: bugfix: raw targets: correctly handle multiple backups in same target directory

pull/93/head
Axel Burri 2016-05-09 12:42:04 +02:00
parent eabdba482e
commit 7326b9816c
2 changed files with 16 additions and 5 deletions

View File

@ -1,5 +1,7 @@
btrbk-current
* Bugfix: raw targets: correctly handle multiple backups in same
target directory (close: #87).
* Use relative instead of absolute binary calls in btrbk-mail.
btrbk-0.23.1

19
btrbk
View File

@ -46,7 +46,7 @@ use Carp qw(confess);
use Getopt::Long qw(GetOptions);
use Time::Local qw( timelocal timegm timegm_nocheck );
our $VERSION = '0.23.1';
our $VERSION = '0.23.2-dev';
our $AUTHOR = 'Axel Burri <axel@tty0.ch>';
our $PROJECT_HOME = '<http://digint.ch/btrbk/>';
@ -4219,6 +4219,7 @@ MAIN:
next;
}
my $snapshot_basename = config_key($svol, "snapshot_name") // die;
my %child_uuid_list;
foreach (split("\n", $ret))
{
@ -4231,20 +4232,28 @@ MAIN:
ABORTED($droot, "Unexpected result from 'find': file \"$file\" is not under \"$droot->{PATH}\"");
last;
}
my $snapshot_basename = config_key($svol, "snapshot_name") // die;
# Set btrfs subvolume information (received_uuid, parent_uuid) from filename info.
#
# NOTE: remote_parent_uuid in BTRBK_RAW is the "parent of the source subvolume", NOT the
# "parent of the received subvolume".
my $subvol = vinfo_child($droot, $file);
unless(vinfo_inject_child($droot, $subvol, { TARGET_TYPE => 'raw' }) &&
defined($subvol->{node}{BTRBK_RAW}) &&
($snapshot_basename eq $subvol->{node}{BTRBK_BASENAME}))
unless(vinfo_inject_child($droot, $subvol, { TARGET_TYPE => 'raw' }))
{
DEBUG "Skipping file (filename scheme mismatch): \"$file\"";
next;
}
unless(defined($subvol->{node}{BTRBK_RAW}) &&
($snapshot_basename eq $subvol->{node}{BTRBK_BASENAME}))
{
# vinfo_inject_child() pushes all "valid" subvols to $droot->{SUBVOL_LIST},
# remove the non-matching ones again.
# If we don't remove them from the list, they will also
# be taken into account for incremental backups!
pop @{$droot->{SUBVOL_LIST}};
DEBUG "Skipping file (base name != \"$snapshot_basename\"): \"$file\"";
next;
}
# incomplete raw fakes get same semantics as real subvolumes (readonly=0, received_uuid='-')
$subvol->{node}{received_uuid} = ($subvol->{node}{BTRBK_RAW}->{incomplete} ? '-' : $subvol->{node}{BTRBK_RAW}->{received_uuid});