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:
- https://superuser.com/questions/168749/is-there-a-way-to-see-any-tar-progress-per-file
- https://matoski.com/article/xz-compress-directory/
- https://tukaani.org/xz/
- https://www.digitalocean.com/community/tutorials/an-introduction-to-file-compression-tools-on-linux-servers
- https://www.rootusers.com/gzip-vs-bzip2-vs-xz-performance-comparison/
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