mirror of https://github.com/digint/btrbk
btrbk: prepare for multiple pre-config commands
Preparatory for extents-diff commandextents-diff
parent
d9d3def390
commit
075fb8bfad
43
btrbk
43
btrbk
|
@ -4842,7 +4842,7 @@ MAIN:
|
||||||
WARN 'Found option "--progress", but required executable "pv" does not exist on your system. Please install "pv".';
|
WARN 'Found option "--progress", but required executable "pv" does not exist on your system. Please install "pv".';
|
||||||
$show_progress = 0;
|
$show_progress = 0;
|
||||||
}
|
}
|
||||||
my ($action_run, $action_usage, $action_resolve, $action_diff, $action_origin, $action_config_print, $action_list, $action_clean, $action_archive);
|
my ($action_run, $action_usage, $action_resolve, $action_noconf, $action_origin, $action_config_print, $action_list, $action_clean, $action_archive);
|
||||||
my @filter_args;
|
my @filter_args;
|
||||||
my @subvol_args;
|
my @subvol_args;
|
||||||
my $args_expected_min = 0;
|
my $args_expected_min = 0;
|
||||||
|
@ -4883,7 +4883,7 @@ MAIN:
|
||||||
@filter_args = @ARGV;
|
@filter_args = @ARGV;
|
||||||
}
|
}
|
||||||
elsif ($command eq "diff") {
|
elsif ($command eq "diff") {
|
||||||
$action_diff = 1;
|
$action_noconf = "diff";
|
||||||
$args_expected_min = $args_expected_max = 2;
|
$args_expected_min = $args_expected_max = 2;
|
||||||
@subvol_args = @ARGV;
|
@subvol_args = @ARGV;
|
||||||
}
|
}
|
||||||
|
@ -5003,28 +5003,33 @@ MAIN:
|
||||||
INFO "$VERSION_INFO (" . localtime($start_time) . ")";
|
INFO "$VERSION_INFO (" . localtime($start_time) . ")";
|
||||||
action("startup", status => "v$VERSION", message => $VERSION_INFO, time => $start_time);
|
action("startup", status => "v$VERSION", message => $VERSION_INFO, time => $start_time);
|
||||||
|
|
||||||
if($action_diff)
|
if($action_noconf)
|
||||||
{
|
{
|
||||||
#
|
|
||||||
# print snapshot diff
|
|
||||||
#
|
|
||||||
my $src_url = $subvol_args[0] || die;
|
|
||||||
my $target_url = $subvol_args[1] || die;
|
|
||||||
my $default_config = init_config();
|
|
||||||
# NOTE: ssh://{src,target} uses default config
|
# NOTE: ssh://{src,target} uses default config
|
||||||
|
my $default_config = init_config();
|
||||||
|
|
||||||
my $src_vol = vinfo($src_url, $default_config);
|
my @diff_vol = map { vinfo($_, $default_config) } @subvol_args;
|
||||||
unless(vinfo_init_root($src_vol)) { ERROR "Failed to fetch subvolume detail for '$src_vol->{PRINT}'" . ($err ? ": $err" : ""); exit 1; }
|
my $src_vol = $diff_vol[0];
|
||||||
if($src_vol->{node}{is_root}) { ERROR "Subvolume is btrfs root: $src_vol->{PRINT}"; exit 1; }
|
foreach (@diff_vol) {
|
||||||
|
unless(vinfo_init_root($_)) {
|
||||||
my $target_vol = vinfo($target_url, $default_config);
|
ERROR "Failed to fetch subvolume detail for '$_->{PRINT}'" . ($err ? ": $err" : "");
|
||||||
unless(vinfo_init_root($target_vol)) { ERROR "Failed to fetch subvolume detail for '$target_vol->{PRINT}'" . ($err ? ": $err" : ""); exit 1; }
|
exit 1;
|
||||||
if($target_vol->{node}{is_root}) { ERROR "Subvolume is btrfs root: $target_vol->{PRINT}"; exit 1; }
|
}
|
||||||
|
if($_->{node}{is_root}) {
|
||||||
unless(_is_same_fs_tree($src_vol->{node}, $target_vol->{node})) {
|
ERROR "Subvolume is btrfs root: $_->{PRINT}";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
unless(_is_same_fs_tree($src_vol->{node}, $_->{node})) {
|
||||||
ERROR "Subvolumes are not on the same btrfs filesystem!";
|
ERROR "Subvolumes are not on the same btrfs filesystem!";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($action_noconf eq "diff") {
|
||||||
|
#
|
||||||
|
# print snapshot diff (btrfs find-new)
|
||||||
|
#
|
||||||
|
my $target_vol = $diff_vol[1];
|
||||||
|
|
||||||
# NOTE: in some cases "cgen" differs from "gen", even for read-only snapshots (observed: gen=cgen+1)
|
# NOTE: in some cases "cgen" differs from "gen", even for read-only snapshots (observed: gen=cgen+1)
|
||||||
my $lastgen = $src_vol->{node}{gen} + 1;
|
my $lastgen = $src_vol->{node}{gen} + 1;
|
||||||
|
@ -5084,6 +5089,8 @@ MAIN:
|
||||||
print " $name\n";
|
print " $name\n";
|
||||||
}
|
}
|
||||||
print "\nTotal size: $total_len bytes\n";
|
print "\nTotal size: $total_len bytes\n";
|
||||||
|
}
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue