Skip to content

Commit 7c8a50b

Browse files
committed
Added zstd support to MYSQL and PostgreSQL backup methods
1 parent ff4c42a commit 7c8a50b

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

backup-manager.conf.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export BM_MYSQL_HOST="localhost"
218218
# the port where MySQL listen to on the host
219219
export BM_MYSQL_PORT="3306"
220220

221-
# which compression format to use? (gzip or bzip2)
221+
# which compression format to use? (gzip, bzip2 or zstd)
222222
export BM_MYSQL_FILETYPE="bzip2"
223223

224224
# Extra options to append to mysqldump
@@ -255,7 +255,7 @@ export BM_PGSQL_HOST="localhost"
255255
# the port where PostgreSQL listen to on the host
256256
export BM_PGSQL_PORT="5432"
257257

258-
# which compression format to use? (gzip or bzip2)
258+
# which compression format to use? (gzip, bzip2 or zstd)
259259
export BM_PGSQL_FILETYPE="bzip2"
260260

261261
# Extra options to append to pg_dump

lib/backup-methods.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,42 @@ function __exec_meta_command()
196196
error "Compressor \$compress is needed."
197197
fi
198198
;;
199+
"zstd"|"zst")
200+
if [[ "$compress" = "zstd" ]] ||
201+
[[ "$compress" = "zst" ]]; then
202+
compress_bin=$zstd
203+
if [[ -z "$compress_bin" ]]; then
204+
error "zstd is not installed but zstd compression needed."
205+
fi
206+
ext="zst"
207+
fi
208+
if [[ -n "$compress_bin" ]] && [[ -x "$compress_bin" ]]; then
209+
debug "$command > $file_to_create 2> $logfile"
210+
tail_logfile "$logfile"
211+
if [[ "$BM_ENCRYPTION_METHOD" = "gpg" ]]; then
212+
warning "Encryption with gpg is not supported with zstd compression at this release."
213+
else
214+
$command 2> $logfile | $nice $compress_bin -f -q --rm > $file_to_create.$ext 2> $logfile
215+
cmdpipestatus=${PIPESTATUS[0]}
216+
debug "$command 2> $logfile | $nice $compress_bin -f -q --rm > $file_to_create.$ext 2> $logfile"
217+
file_to_create="$file_to_create.$ext"
218+
fi
219+
220+
if [[ $? -gt 0 ]]; then
221+
warning "Unable to exec \$command; check \$logfile"
222+
rm -f $file_to_create
223+
else
224+
if [[ $cmdpipestatus -gt 0 ]]; then
225+
warning "Unable to exec first piped command \$command; check \$logfile"
226+
rm -f $file_to_create
227+
else
228+
rm -f $logfile
229+
fi
230+
fi
231+
else
232+
error "Compressor \$compress is needed."
233+
fi
234+
;;
199235
""|"uncompressed"|"none")
200236
if [[ "$verbosedebug" == "true" ]]; then
201237
tail -f $logfile &

0 commit comments

Comments
 (0)