mirror of https://github.com/digint/btrbk
btrbk: check source AND targets for determining snapshot postfix
parent
a90033c1aa
commit
8f9cafb359
|
@ -1,6 +1,8 @@
|
||||||
btrbk-current
|
btrbk-current
|
||||||
|
|
||||||
* Bugfix: allow "0" as subvolume name (closes: #10)
|
* Bugfix: allow "0" as subvolume name (closes: #10)
|
||||||
|
* Bugfix: check source AND targets for determining snapshot postfix
|
||||||
|
(closes: #11)
|
||||||
|
|
||||||
btrbk-0.16
|
btrbk-0.16
|
||||||
|
|
||||||
|
|
23
btrbk
23
btrbk
|
@ -1529,16 +1529,21 @@ MAIN:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# find new snapshot name
|
# find unique snapshot name
|
||||||
my $postfix_counter = -1;
|
my @lookup = keys %{$vol_info{$sroot}};
|
||||||
my $postfix;
|
@lookup = grep s/^$snapdir// , @lookup;
|
||||||
do {
|
foreach (@{$config_subvol->{TARGET}}){
|
||||||
|
push(@lookup, keys %{$vol_info{$_->{droot}}});
|
||||||
|
}
|
||||||
|
@lookup = grep /^$svol\.$timestamp(_[0-9]+)?$/ ,@lookup;
|
||||||
|
TRACE "Present snapshot names for \"$sroot/$svol\": " . join(', ', @lookup);
|
||||||
|
@lookup = map { /_([0-9]+)$/ ? $1 : 0 } @lookup;
|
||||||
|
@lookup = sort { $b <=> $a } @lookup;
|
||||||
|
my $postfix_counter = $lookup[0] // -1;
|
||||||
$postfix_counter++;
|
$postfix_counter++;
|
||||||
$postfix = '.' . $timestamp . ($postfix_counter ? "_$postfix_counter" : "");
|
|
||||||
TRACE "Testing source snapshot name: $snapdir$svol$postfix";
|
$snapshot_name = $svol . '.' . $timestamp . ($postfix_counter ? "_$postfix_counter" : "");
|
||||||
} while(subvol($sroot, "$snapdir$svol$postfix")); # NOTE: $snapdir always has trailing slash!
|
$snapshot = "$sroot/$snapdir$snapshot_name";
|
||||||
$snapshot = "$sroot/$snapdir$svol$postfix";
|
|
||||||
$snapshot_name = "$svol$postfix";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $create_snapshot = config_key($config_subvol, "snapshot_create_always");
|
my $create_snapshot = config_key($config_subvol, "snapshot_create_always");
|
||||||
|
|
Loading…
Reference in New Issue