Skip to content

Commit

Permalink
Added zstd support to MYSQL and PostgreSQL backup methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cmilanf committed Jul 27, 2024
1 parent ff4c42a commit 7c8a50b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backup-manager.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export BM_MYSQL_HOST="localhost"
# the port where MySQL listen to on the host
export BM_MYSQL_PORT="3306"

# which compression format to use? (gzip or bzip2)
# which compression format to use? (gzip, bzip2 or zstd)
export BM_MYSQL_FILETYPE="bzip2"

# Extra options to append to mysqldump
Expand Down Expand Up @@ -255,7 +255,7 @@ export BM_PGSQL_HOST="localhost"
# the port where PostgreSQL listen to on the host
export BM_PGSQL_PORT="5432"

# which compression format to use? (gzip or bzip2)
# which compression format to use? (gzip, bzip2 or zstd)
export BM_PGSQL_FILETYPE="bzip2"

# Extra options to append to pg_dump
Expand Down
36 changes: 36 additions & 0 deletions lib/backup-methods.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,42 @@ function __exec_meta_command()
error "Compressor \$compress is needed."
fi
;;
"zstd"|"zst")
if [[ "$compress" = "zstd" ]] ||
[[ "$compress" = "zst" ]]; then
compress_bin=$zstd
if [[ -z "$compress_bin" ]]; then
error "zstd is not installed but zstd compression needed."
fi
ext="zst"
fi
if [[ -n "$compress_bin" ]] && [[ -x "$compress_bin" ]]; then
debug "$command > $file_to_create 2> $logfile"
tail_logfile "$logfile"
if [[ "$BM_ENCRYPTION_METHOD" = "gpg" ]]; then
warning "Encryption with gpg is not supported with zstd compression at this release."
else
$command 2> $logfile | $nice $compress_bin -f -q --rm > $file_to_create.$ext 2> $logfile
cmdpipestatus=${PIPESTATUS[0]}
debug "$command 2> $logfile | $nice $compress_bin -f -q --rm > $file_to_create.$ext 2> $logfile"
file_to_create="$file_to_create.$ext"
fi

if [[ $? -gt 0 ]]; then
warning "Unable to exec \$command; check \$logfile"
rm -f $file_to_create
else
if [[ $cmdpipestatus -gt 0 ]]; then
warning "Unable to exec first piped command \$command; check \$logfile"
rm -f $file_to_create
else
rm -f $logfile
fi
fi
else
error "Compressor \$compress is needed."
fi
;;
""|"uncompressed"|"none")
if [[ "$verbosedebug" == "true" ]]; then
tail -f $logfile &
Expand Down

0 comments on commit 7c8a50b

Please sign in to comment.