diff options
author | Erich Eckner <git@eckner.net> | 2018-06-13 16:22:08 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-06-13 16:22:08 +0200 |
commit | 1433976802baf67c89038d699d0a50522bc138cc (patch) | |
tree | 10c3b0adb34c644fdbeaf20a2a09b925c495987c /lib/common-functions | |
parent | d7d699efe7941f626617e952fb8ecf057f493ec8 (diff) | |
download | builder-1433976802baf67c89038d699d0a50522bc138cc.tar.xz |
lib/common-functions: recompress_gz() new to recompress databases before sending, so they are transferred faster by rsync
Diffstat (limited to 'lib/common-functions')
-rwxr-xr-x | lib/common-functions | 20 |
1 files changed, 20 insertions, 0 deletions
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}" +} |