From 47995ef1bb738246e41891e021228a259da75430 Mon Sep 17 00:00:00 2001 From: Christoph Anton Mitterer Date: Tue, 15 Nov 2022 03:20:24 +0100 Subject: [PATCH] btrbk: add bzip3 compression This adds support for bzip3 (https://github.com/kspalaiologos/bzip3). Signed-off-by: Christoph Anton Mitterer --- btrbk | 5 +++-- contrib/migration/raw_suffix2sidecar | 4 ++-- doc/btrbk.conf.5.asciidoc | 14 +++++++------- doc/ssh_filter_btrbk.1.asciidoc | 4 ++-- ssh_filter_btrbk.sh | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/btrbk b/btrbk index bc9f708..67dd6ad 100755 --- a/btrbk +++ b/btrbk @@ -51,6 +51,7 @@ my %compression = ( gzip => { name => 'gzip', format => 'gz', compress_cmd => [ 'gzip', '-c' ], decompress_cmd => [ 'gzip', '-d', '-c' ], level_min => 1, level_max => 9 }, pigz => { name => 'pigz', format => 'gz', compress_cmd => [ 'pigz', '-c' ], decompress_cmd => [ 'pigz', '-d', '-c' ], level_min => 1, level_max => 9, threads => '-p' }, bzip2 => { name => 'bzip2', format => 'bz2', compress_cmd => [ 'bzip2', '-c' ], decompress_cmd => [ 'bzip2', '-d', '-c' ], level_min => 1, level_max => 9 }, + bzip3 => { name => 'bzip3', format => 'bz3', compress_cmd => [ 'bzip3', '-c' ], decompress_cmd => [ 'bzip3', '-d', '-c' ], level_min => -1, level_max => -1, threads => '-j' }, pbzip2 => { name => 'pbzip2', format => 'bz2', compress_cmd => [ 'pbzip2', '-c' ], decompress_cmd => [ 'pbzip2', '-d', '-c' ], level_min => 1, level_max => 9, threads => '-p' }, xz => { name => 'xz', format => 'xz', compress_cmd => [ 'xz', '-c' ], decompress_cmd => [ 'xz', '-d', '-c' ], level_min => 0, level_max => 9, threads => '-T' }, lzo => { name => 'lzo', format => 'lzo', compress_cmd => [ 'lzop', '-c' ], decompress_cmd => [ 'lzop', '-d', '-c' ], level_min => 1, level_max => 9 }, @@ -64,7 +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_timestamp_match = qr/(?[0-9]{4})(?[0-9]{2})(?
[0-9]{2})(T(?[0-9]{2})(?[0-9]{2})((?[0-9]{2})(?(Z|[+-][0-9]{4})))?)?(_(?[0-9]+))?/; # matches "YYYYMMDD[Thhmm[ss+0000]][_NN]" -my $raw_postfix_match = qr/\.btrfs(\.($compress_format_alt))?(\.(gpg|encrypted))?/; # matches ".btrfs[.gz|bz2|xz][.gpg|encrypted]" +my $raw_postfix_match = qr/\.btrfs(\.($compress_format_alt))?(\.(gpg|encrypted))?/; # matches ".btrfs[.gz|bz2|bz3|xz][.gpg|encrypted]" my $safe_file_match = qr/[0-9a-zA-Z_@\+\-\.\/]+/; # note: ubuntu uses '@' in the subvolume layout: my $group_match = qr/[a-zA-Z0-9_:-]+/; @@ -2009,7 +2010,7 @@ sub system_read_raw_info_dir($) '-maxdepth', '1', '-type', 'f', '!', '-size', '0', - '-name', '\*.btrfs.\*info', # match ".btrfs[.gz|bz2|xz][.gpg].info" + '-name', '\*.btrfs.\*info', # match ".btrfs[.gz|bz2|bz3|xz][.gpg].info" '-exec', 'echo INFO_FILE=\{\} \;', '-exec', 'cat \{\} \;' ], diff --git a/contrib/migration/raw_suffix2sidecar b/contrib/migration/raw_suffix2sidecar index 0b17cc9..624c12e 100755 --- a/contrib/migration/raw_suffix2sidecar +++ b/contrib/migration/raw_suffix2sidecar @@ -38,11 +38,11 @@ our $PROJECT_HOME = ''; my $VERSION_INFO = "raw_suffix2sidecar (btrbk migration script), version $VERSION"; -my $compress_format_alt = 'gz|bz2|xz|lzo|lz4'; +my $compress_format_alt = 'gz|bz2|bz3|xz|lzo|lz4'; my $file_match = qr/[0-9a-zA-Z_@\+\-\.\/]+/; # note: ubuntu uses '@' in the subvolume layout: 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 $timestamp_postfix_match = qr/\.(?[0-9]{4})(?[0-9]{2})(?
[0-9]{2})(T(?[0-9]{2})(?[0-9]{2})((?[0-9]{2})(?(Z|[+-][0-9]{4})))?)?(_(?[0-9]+))?/; # matches "YYYYMMDD[Thhmm[ss+0000]][_NN]" -my $raw_postfix_match = qr/--(?$uuid_match)(\@(?$uuid_match))?\.btrfs?(\.(?($compress_format_alt)))?(\.(?gpg))?(\.(?split_aa))?(\.(?part))?/; # matches ".btrfs_[@][.gz|bz2|xz][.gpg][.split_aa][.part]" +my $raw_postfix_match = qr/--(?$uuid_match)(\@(?$uuid_match))?\.btrfs?(\.(?($compress_format_alt)))?(\.(?gpg))?(\.(?split_aa))?(\.(?part))?/; # matches ".btrfs_[@][.gz|bz2|bz3|xz][.gpg][.split_aa][.part]" my $dryrun; diff --git a/doc/btrbk.conf.5.asciidoc b/doc/btrbk.conf.5.asciidoc index 2c21954..85b7103 100644 --- a/doc/btrbk.conf.5.asciidoc +++ b/doc/btrbk.conf.5.asciidoc @@ -273,8 +273,8 @@ set to ``all'' (the default). Compress the btrfs send stream before transferring it from/to remote locations. Defaults to ``no''. If enabled, make sure that '' is available on the source and target - hosts. Supported '': gzip, pigz, bzip2, pbzip2, - xz, lzo, lz4, zstd. + hosts. Supported '': gzip, pigz, bzip2, bzip3, + pbzip2, xz, lzo, lz4, zstd. *stream_compress_level* default|:: Compression level for the specified ''. Refer to @@ -289,7 +289,7 @@ set to ``all'' (the default). *stream_compress_threads* default|:: Number of threads to use for . Only supported - for "pigz", "pbzip2", "zstd" and recent versions of "xz". + for "pigz", "bzip3", "pbzip2", "zstd" and recent versions of "xz". *stream_compress_adapt* default|:: Enable adaptive compression for . Only supported @@ -612,8 +612,8 @@ files)! Raw backups consist of two files: the main data file containing the btrfs send stream, and a sidecar file ".info" containing metadata: - .[_N].btrfs[.gz|.bz2|.xz][.gpg] - .[_N].btrfs[.gz|.bz2|.xz][.gpg].info + .[_N].btrfs[.gz|.bz2|.bz3|.xz][.gpg] + .[_N].btrfs[.gz|.bz2|.bz3|.xz][.gpg].info For 'incremental' backups ("incremental yes"), please note that: @@ -633,8 +633,8 @@ Additional options for raw targets: *raw_target_compress* |no:: Compression algorithm to use for raw backup target. Supported - '': gzip, pigz, bzip2, pbzip2, xz, lzo, lz4, - zstd. + '': gzip, pigz, bzip2, bzip3, pbzip2, xz, lzo, + lz4, zstd. *raw_target_compress_level* default|:: Compression level for the specified . *raw_target_compress_long* default|:: diff --git a/doc/ssh_filter_btrbk.1.asciidoc b/doc/ssh_filter_btrbk.1.asciidoc index 6b1061c..d2c2a76 100644 --- a/doc/ssh_filter_btrbk.1.asciidoc +++ b/doc/ssh_filter_btrbk.1.asciidoc @@ -39,8 +39,8 @@ The following commands are always allowed: - "readlink" - "test -d" (only if "compat busybox" configuration option is set) - "cat /proc/self/mountinfo" - - pipes through "gzip", "pigz", "bzip2", "pbzip2", "xz", "lzop", - "lz4", "zstd" (stream_compress) + - pipes through "gzip", "pigz", "bzip2", "bzip3", "pbzip2", "xz", + "lzop", "lz4", "zstd" (stream_compress) - pipes through "mbuffer" (stream_buffer, rate_limit) Example line in /root/.ssh/authorized_keys on a backup target host: diff --git a/ssh_filter_btrbk.sh b/ssh_filter_btrbk.sh index 5952f2e..f5ed798 100755 --- a/ssh_filter_btrbk.sh +++ b/ssh_filter_btrbk.sh @@ -12,7 +12,7 @@ allow_exact_list= allow_rate_limit=1 allow_stream_buffer=1 allow_compress=1 -compress_list="gzip|pigz|bzip2|pbzip2|xz|lzop|lz4|zstd" +compress_list="gzip|pigz|bzip2|bzip3|pbzip2|xz|lzop|lz4|zstd" # note that the backslash is NOT a metacharacter in a POSIX bracket expression! option_match='-[a-zA-Z0-9=-]+' # matches short as well as long options