mirror of https://github.com/digint/btrbk
btrbk: use parser function for assembling archive config
parent
443cb1891b
commit
053cd7a59c
50
btrbk
50
btrbk
|
@ -5869,8 +5869,6 @@ MAIN:
|
|||
my $src_root = $subvol_args[0] || die;
|
||||
my $archive_root = $subvol_args[1] || die;
|
||||
|
||||
$config->{SUBSECTION} = []; # clear configured subsections, we build them dynamically
|
||||
|
||||
unless(vinfo_init_root($src_root)) {
|
||||
ERROR "Failed to fetch subvolume detail for '$src_root->{PRINT}'", @stderr;
|
||||
exit 1;
|
||||
|
@ -5880,46 +5878,32 @@ MAIN:
|
|||
exit 1;
|
||||
}
|
||||
|
||||
my $config_volume = { CONTEXT => "volume",
|
||||
PARENT => $config,
|
||||
SUBSECTION => [],
|
||||
DUMMY => 1,
|
||||
url => "/dev/null",
|
||||
};
|
||||
push(@{$config->{SUBSECTION}}, $config_volume);
|
||||
$config->{SUBSECTION} = []; # clear configured subsections, we build them dynamically
|
||||
|
||||
my $cur = $config;
|
||||
my %name_uniq;
|
||||
my @subvol_list = @{vinfo_subvol_list($src_root)};
|
||||
my @sorted = sort { ($a->{subtree_depth} <=> $b->{subtree_depth}) || ($a->{SUBVOL_DIR} cmp $b->{SUBVOL_DIR}) } @subvol_list;
|
||||
foreach my $vol (@sorted) {
|
||||
foreach my $vol (sort { ($a->{subtree_depth} <=> $b->{subtree_depth}) ||
|
||||
($a->{SUBVOL_DIR} cmp $b->{SUBVOL_DIR})
|
||||
} @{vinfo_subvol_list($src_root)})
|
||||
{
|
||||
next unless($vol->{node}{readonly});
|
||||
my $snapshot_name = $vol->{node}{BTRBK_BASENAME};
|
||||
unless(defined($snapshot_name)) {
|
||||
WARN "Skipping subvolume (not a btrbk subvolume): $vol->{PRINT}";
|
||||
next;
|
||||
}
|
||||
my $subvol_dir = $vol->{SUBVOL_DIR};
|
||||
next if($name_uniq{"$subvol_dir/$snapshot_name"});
|
||||
$name_uniq{"$subvol_dir/$snapshot_name"} = 1;
|
||||
my $droot_url = $archive_root->{URL} . ($subvol_dir eq "" ? "" : "/$subvol_dir");
|
||||
my $sroot_url = $src_root->{URL} . ($subvol_dir eq "" ? "" : "/$subvol_dir");
|
||||
my $config_sroot = { # CONTEXT => "archive_source",
|
||||
CONTEXT => "subvolume",
|
||||
PARENT => $config_volume,
|
||||
url => $sroot_url, # ABORTED() needs this
|
||||
snapshot_name => $snapshot_name,
|
||||
snapshot_dir => $sroot_url,
|
||||
};
|
||||
my $config_droot = { # CONTEXT => "archive_target",
|
||||
CONTEXT => "target",
|
||||
PARENT => $config_sroot,
|
||||
target_type => ($archive_raw ? "raw" : "send-receive"), # macro_send_receive checks this
|
||||
url => $droot_url, # ABORTED() needs this
|
||||
target_create_dir => "yes",
|
||||
};
|
||||
$config_sroot->{SUBSECTION} = [ $config_droot ];
|
||||
push(@{$config_volume->{SUBSECTION}}, $config_sroot);
|
||||
my $subdir = $vol->{SUBVOL_DIR} ? "/" . $vol->{SUBVOL_DIR} : "";
|
||||
next if($name_uniq{"$subdir/$snapshot_name"});
|
||||
$name_uniq{"$subdir/$snapshot_name"} = 1;
|
||||
$cur = parse_config_line($cur, $_->[0], $_->[1]) // die for(
|
||||
[ subvolume => $src_root->{URL} . $subdir ],
|
||||
[ snapshot_dir => $src_root->{PATH} . $subdir ],
|
||||
[ snapshot_name => $snapshot_name ],
|
||||
[ target => ($archive_raw ? "raw" : "send-receive") . " '" . $archive_root->{URL} . $subdir . "'" ],
|
||||
[ target_create_dir => "yes" ],
|
||||
);
|
||||
}
|
||||
_config_propagate_target($config);
|
||||
|
||||
# translate archive_exclude globs, add to exclude args
|
||||
my $archive_exclude = config_key($config, 'archive_exclude') // [];
|
||||
|
|
Loading…
Reference in New Issue