btrbk: honor timeshift format in get_btrbk_snapshot_siblings

action-cp
Axel Burri 2022-06-26 15:17:11 +02:00
parent d9dbc432c3
commit 5665fae87c
1 changed files with 5 additions and 1 deletions

6
btrbk
View File

@ -65,6 +65,7 @@ my $ipv6_addr_match = qr/[a-fA-F0-9]*:[a-fA-F0-9]*:[a-fA-F0-9:]+/; # simplified
my $host_name_match = qr/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])/;
my $uuid_match = qr/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
my $btrbk_file_match = qr/(?<name>.+)\.(?<YYYY>[0-9]{4})(?<MM>[0-9]{2})(?<DD>[0-9]{2})(T(?<hh>[0-9]{2})(?<mm>[0-9]{2})((?<ss>[0-9]{2})(?<zz>(Z|[+-][0-9]{4})))?)?(_(?<NN>[0-9]+))?/; # matches "NAME.YYYYMMDD[Thhmm[ss+0000]][_NN]"
my $timeshift_file_match = qr/(?<YYYY>[0-9]{4})-(?<MM>[0-9]{2})-(?<DD>[0-9]{2})_(?<hh>[0-9]{2})-(?<mm>[0-9]{2})-(?<ss>[0-9]{2})\/(?<name>[^\/]+)/; # matches "YYYY-MM-DD_hh-mm-ss/NAME"
my $raw_postfix_match = qr/\.btrfs(\.($compress_format_alt))?(\.(gpg|encrypted))?/; # matches ".btrfs[.gz|.bz2|.xz|...][.gpg|.encrypted]"
my $safe_file_match = qr/[0-9a-zA-Z_@\+\-\.\/]+/; # note: ubuntu uses '@' in the subvolume layout: <https://help.ubuntu.com/community/btrfs>
@ -2839,6 +2840,9 @@ sub add_btrbk_filename_info($;$)
if($rel_path =~ /^(?:(?<subdir>.*)\/)?$btrbk_file_match$/) {
%match = ( %+, family => "btrbk" );
}
elsif($rel_path =~ /^(?:(?<subdir>.*)\/)?$timeshift_file_match$/) {
%match = ( %+, family => "timeshift" );
}
};
return undef unless $match{name};
my $btrbk_date = _get_btrbk_date(%match); # use named capture buffers of previous match
@ -3758,7 +3762,7 @@ sub get_best_parent($$;@)
next if(grep { $_->[0]{node}{id} == $cc->[0]{node}{id} } @parent);
DEBUG "Resolved " . (@parent ? "clone source" : "parent") . " (" .
"next closest " . ($k =~ /n/ ? "newer" : "older") .
" by " . ($k =~ /s/ ? "btrbk timestamp in snapdir" : "cgen") .
" by " . ($k =~ /s/ ? "timestamp in snapdir" : "cgen") .
", " . ($k =~ /r/ ? "with" : "regardless of") . " parent_uuid relationship" .
"): $cc->[0]{PRINT}" if($loglevel >= 3);
push @parent, $cc;