mirror of https://github.com/digint/btrbk
btrbk: added configuration options "raw_target_compress_level", "raw_target_compress_threads"
parent
3461f9440b
commit
a82c1f533a
|
@ -5,6 +5,8 @@ btrbk-current
|
||||||
when using perl-5.22.0 (close: #57).
|
when using perl-5.22.0 (close: #57).
|
||||||
* Added "clean" command (close: #61).
|
* Added "clean" command (close: #61).
|
||||||
* Added "-n, --dry-run" option.
|
* Added "-n, --dry-run" option.
|
||||||
|
* Added configuration options "raw_target_compress_level",
|
||||||
|
"raw_target_compress_threads" (close: #60).
|
||||||
|
|
||||||
btrbk-0.21.0
|
btrbk-0.21.0
|
||||||
|
|
||||||
|
|
42
btrbk
42
btrbk
|
@ -94,6 +94,8 @@ my %config_options = (
|
||||||
transaction_log => { default => undef, accept_file => { absolute => 1 } },
|
transaction_log => { default => undef, accept_file => { absolute => 1 } },
|
||||||
|
|
||||||
raw_target_compress => { default => undef, accept => [ "no", "gzip", "bzip2", "xz" ] },
|
raw_target_compress => { default => undef, accept => [ "no", "gzip", "bzip2", "xz" ] },
|
||||||
|
raw_target_compress_level => { default => "default", accept => [ "default" ], accept_numeric => 1 },
|
||||||
|
raw_target_compress_threads => { default => "default", accept => [ "default" ], accept_numeric => 1 },
|
||||||
raw_target_encrypt => { default => undef, accept => [ "no", "gpg" ] },
|
raw_target_encrypt => { default => undef, accept => [ "no", "gpg" ] },
|
||||||
gpg_keyring => { default => undef, accept_file => { absolute => 1 } },
|
gpg_keyring => { default => undef, accept_file => { absolute => 1 } },
|
||||||
gpg_recipient => { default => undef, accept_regexp => qr/^[0-9a-zA-Z_@\+\-\.]+$/ },
|
gpg_recipient => { default => undef, accept_regexp => qr/^[0-9a-zA-Z_@\+\-\.]+$/ },
|
||||||
|
@ -1358,9 +1360,9 @@ sub btrfs_send_to_file($$$$;@)
|
||||||
$target_filename .= '@' . $parent_uuid if($parent_uuid);
|
$target_filename .= '@' . $parent_uuid if($parent_uuid);
|
||||||
$target_filename .= ".btrfs";
|
$target_filename .= ".btrfs";
|
||||||
|
|
||||||
my %compress = ( gzip => { pipe => { cmd => [ 'gzip' ], name => 'gzip' }, postfix => '.gz' },
|
my %compress = ( gzip => { name => 'gzip' , cmd => [ 'gzip' ], postfix => '.gz', level_min => 1, level_max => 9 },
|
||||||
bzip2 => { pipe => { cmd => [ 'bzip2' ], name => 'bzip2' }, postfix => '.bz2' },
|
bzip2 => { name => 'bzip2', cmd => [ 'bzip2' ], postfix => '.bz2', level_min => 1, level_max => 9 },
|
||||||
xz => { pipe => { cmd => [ 'xz' ], name => 'xz' }, postfix => '.xz' },
|
xz => { name => 'xz' , cmd => [ 'xz' ], postfix => '.xz', level_min => 0, level_max => 9, threads => '--threads=' },
|
||||||
);
|
);
|
||||||
|
|
||||||
my @send_options;
|
my @send_options;
|
||||||
|
@ -1379,7 +1381,31 @@ sub btrfs_send_to_file($$$$;@)
|
||||||
if($opts{compress}) {
|
if($opts{compress}) {
|
||||||
die unless($compress{$opts{compress}});
|
die unless($compress{$opts{compress}});
|
||||||
$target_filename .= $compress{$opts{compress}}->{postfix};
|
$target_filename .= $compress{$opts{compress}}->{postfix};
|
||||||
push @cmd_pipe, $compress{$opts{compress}}->{pipe};
|
my $compress_cmd = $compress{$opts{compress}}->{cmd};
|
||||||
|
if(defined($opts{compress_level}) && ($opts{compress_level} ne "default")) {
|
||||||
|
my $compress_level = $opts{compress_level};
|
||||||
|
if($compress_level < $compress{$opts{compress}}->{level_min}) {
|
||||||
|
WARN "Compression level (raw_target_compress_level) capped to minimum for '$opts{compress}': $compress{$opts{compress}}->{level_min}";
|
||||||
|
$compress_level = $compress{$opts{compress}}->{level_min};
|
||||||
|
}
|
||||||
|
if($compress_level > $compress{$opts{compress}}->{level_max}) {
|
||||||
|
WARN "Compression level (raw_target_compress_level) capped to maximum for '$opts{compress}': $compress{$opts{compress}}->{level_max}";
|
||||||
|
$compress_level = $compress{$opts{compress}}->{level_max};
|
||||||
|
}
|
||||||
|
push @$compress_cmd, '-' . $compress_level;
|
||||||
|
}
|
||||||
|
if(defined($opts{compress_threads}) && ($opts{compress_threads} ne "default")) {
|
||||||
|
my $thread_opt = $compress{$opts{compress}}->{threads};
|
||||||
|
if($thread_opt) {
|
||||||
|
push @$compress_cmd, $thread_opt . $opts{compress_threads};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WARN "Threading (raw_target_compress_threads) is not supported for '$opts{compress}', ignoring";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
push @cmd_pipe, { cmd => $compress_cmd,
|
||||||
|
name => $compress{$opts{compress}}->{name}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
if($opts{encrypt}) {
|
if($opts{encrypt}) {
|
||||||
die unless($opts{encrypt}->{type} eq "gpg");
|
die unless($opts{encrypt}->{type} eq "gpg");
|
||||||
|
@ -1635,7 +1661,6 @@ sub macro_send_receive($@)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $compress = config_key($config_target, "raw_target_compress");
|
|
||||||
my $encrypt = undef;
|
my $encrypt = undef;
|
||||||
my $encrypt_type = config_key($config_target, "raw_target_encrypt");
|
my $encrypt_type = config_key($config_target, "raw_target_encrypt");
|
||||||
if($encrypt_type) {
|
if($encrypt_type) {
|
||||||
|
@ -1645,7 +1670,12 @@ sub macro_send_receive($@)
|
||||||
recipient => config_key($config_target, "gpg_recipient"),
|
recipient => config_key($config_target, "gpg_recipient"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ret = btrfs_send_to_file($snapshot, $target, $parent, \$vol_received, compress => $compress, encrypt => $encrypt);
|
$ret = btrfs_send_to_file($snapshot, $target, $parent, \$vol_received,
|
||||||
|
compress => config_key($config_target, "raw_target_compress"),
|
||||||
|
compress_level => config_key($config_target, "raw_target_compress_level"),
|
||||||
|
compress_threads => config_key($config_target, "raw_target_compress_threads"),
|
||||||
|
encrypt => $encrypt
|
||||||
|
);
|
||||||
ABORTED($config_target, "Failed to send subvolume to raw file") unless($ret);
|
ABORTED($config_target, "Failed to send subvolume to raw file") unless($ret);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -246,6 +246,10 @@ Additional options for raw targets:
|
||||||
raw_target_compress gzip|bzip2|xz|no
|
raw_target_compress gzip|bzip2|xz|no
|
||||||
.PD 0
|
.PD 0
|
||||||
.PP
|
.PP
|
||||||
|
raw_target_compress_level default|<number>
|
||||||
|
.PP
|
||||||
|
raw_target_compress_threads default|<number>
|
||||||
|
.PP
|
||||||
raw_target_encrypt gpg|no
|
raw_target_encrypt gpg|no
|
||||||
.PP
|
.PP
|
||||||
gpg_keyring <file>
|
gpg_keyring <file>
|
||||||
|
|
Loading…
Reference in New Issue