From 1433976802baf67c89038d699d0a50522bc138cc Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 13 Jun 2018 16:22:08 +0200 Subject: lib/common-functions: recompress_gz() new to recompress databases before sending, so they are transferred faster by rsync --- lib/common-functions | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib') diff --git a/lib/common-functions b/lib/common-functions index d8da4a7..aa78ebd 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -758,3 +758,23 @@ verbose_flock() { return ${err} } } + +# recompress_gz $tmp_dir $file1.gz $file2.gz ... +# recompress the given file(s) to make them rsync friendly +recompress_gz() { + tmp_file=$( + mktemp "$1/recompress_gz.XXXXXXXX)" + ) + shift + local file + for file in "$@"; do + if [ ! -f "${file}" ]; then + continue + fi + mv "${file}" "${tmp_file}" + zcat "${tmp_file}" | \ + gzip --best --rsyncable > \ + "${file}" + done + rm "${tmp_file}" +} -- cgit v1.2.3