Compress a directory using multiple threads and show a progress bar with this script:
#!/usr/bin/env bash
# example: tar_cJf.sh ./directory > directory.tar.xz
SOURCE="$1"
# get source size
SOURCE_SIZE=$(du -sk "${SOURCE}" | cut -f1)
# archive and compress
tar -cf - "${SOURCE}" | pv -p -s "${SOURCE_SIZE}k" | xz -6 --threads=6 -c -
sources:
Thanks for this tips !
For information,
--threads=6
can be withdrawn for the moment because it has not been implementedActually,
man xz
on version5.2.4
give :A small tips : the option
-v
to xz show a progress indicator