summaryrefslogtreecommitdiff
path: root/lib/common-functions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common-functions')
-rwxr-xr-xlib/common-functions20
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}"
+}