From 85e34c73a3e02057319580eeed448967e5f9c442 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Tue, 9 Feb 2021 08:22:48 -0700 Subject: [PATCH] feature(BACKUP): add compression option - parameter to specify compression used by borg - as requested by shaneonabike (via github) Closes github 5 --- backup/backup.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/backup/backup.sh b/backup/backup.sh index 9d516f8..64a10f3 100755 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -164,6 +164,10 @@ scriptHelp() { textblock "Path to write log file" defaultsTextblock "(scriptPath/scriptName.log)" newline + switchTextblock "--compression" + textblock "Compression algorithm(s) that borg should use. Please run 'borg help compression' for details." + defaultsTextblock "(not specified, use borg default of lz4)" + newline switchTextblock "[SWITCH] -v | --verbose" textblock "Log borg output with increased verbosity (list all files). Careful! Your log file can get very large very quickly!" defaultsTextblock "(normal output, option is OFF)" @@ -300,6 +304,15 @@ while [ $# -gt 0 ]; do badParam empty "$@" fi ;; + --compression) + # set borg archive compression + if [ -n "$2" ]; then + borgCompression="$2" + shift + else + badParam empty "$@" + fi + ;; -v|--verbose) # set verbose logging from borg borgCreateParams='--list --stats' @@ -419,7 +432,10 @@ fi if [ ! -f "$mcDockerCompose" ]; then badParam dne "(--docker-compose)" "$mcDockerCompose" fi - +# set compression level if specified +if [ -n "$borgCompression" ]; then + borgCreateParams="${borgCreateParams} --compression ${borgCompression}" +fi ### read mailcow.conf and set vars as needed # shellcheck source=./mailcow.conf.shellcheck