From 24bd8648e500a17cd5e62b229613f977241d585c Mon Sep 17 00:00:00 2001 From: Amir Ahmad Date: Wed, 30 Oct 2024 11:06:30 +1100 Subject: [PATCH] Support zstd as a compression backend zstd is faster at compressing and decompressing than gzip, and results in small files --- lib/backends/s3.bash | 6 ++++++ lib/backends/tarball.bash | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/backends/s3.bash b/lib/backends/s3.bash index c39d338..260a509 100644 --- a/lib/backends/s3.bash +++ b/lib/backends/s3.bash @@ -33,6 +33,12 @@ if [[ ! "$OSTYPE" == "darwin"* ]]; then fi BK_TAR_EXTENSION="tar.gz" BK_TAR_EXTRACT_ARGS="-xzf" + + if [[ "${BK_CACHE_COMPRESS_PROGRAM}" == zstd ]]; then + BK_TAR_EXTENSION="tar.zst" + BK_TAR_ARGS=("$BK_TAR_ADDITIONAL_ARGS" --use-compress-program "zstd" -cf) + BK_TAR_EXTRACT_ARGS="--use-compress-program zstd -xf" + fi else BK_TAR_ARGS=("$BK_TAR_ADDITIONAL_ARGS" -cf) fi diff --git a/lib/backends/tarball.bash b/lib/backends/tarball.bash index e3aeb6d..9f61ecf 100644 --- a/lib/backends/tarball.bash +++ b/lib/backends/tarball.bash @@ -34,6 +34,12 @@ if [[ ! "$OSTYPE" == "darwin"* ]]; then fi BK_TAR_EXTENSION="tar.gz" BK_TAR_EXTRACT_ARGS="-xzf" + + if [[ "${BK_CACHE_COMPRESS_PROGRAM}" == zstd ]]; then + BK_TAR_EXTENSION="tar.zst" + BK_TAR_ARGS=("$BK_TAR_ADDITIONAL_ARGS" --use-compress-program "zstd" -cf) + BK_TAR_EXTRACT_ARGS="--use-compress-program zstd -xf" + fi else BK_TAR_ARGS=("$BK_TAR_ADDITIONAL_ARGS" -cf) fi