Parallel Gzip

Lzop use to be my favorite fast compression program. That is until I learned about parallels gzip (pigz)
enter image description here

Compress a Folder

# compress a folder called "myfolder" at maximum compression using six threads
tar cf - myfolder | pigz -9 -p 6 > myfolder.tar.gz

Compress a Folder (Using Variables):

# compress a folder called "/myfolder" at maximum compression using six threads
FOLDER-NAME=/myfolder
COMPRESSION-LEVEL=9
THREADS=6
tar cf - ${FOLDER-NAME} | pigz -${COMPRESSION-LEVEL} -p ${THREADS} > ${FOLDER-NAME}.tar.gz

Backup Mysql and Compress Output

BACKUP_DEST="/backup/backups"
OSSIM_VERSION=$(dpkg -l | grep ossim-cd-tools | awk '{print $3}' | awk -F'-' '{ print $1 }')
OSSIM_HOSTNAME=$(cat /etc/hostname)
OSSIM_MYSQLPW=$(grep ^pass /etc/ossim/ossim_setup.conf | sed 's/pass=//')
TIMESTAMP_NOW=$(date "+%Y-%m-%d--%H-%M")

cd ${BACKUP_PATH}
mysqldump -p${OSSIM_MYSQLPW} \
--no-autocommit \
--single-transaction \
--all-databases \
| pigz > ${BACKUP_PATH}/${TIMESTAMP_NOW}-${OSSIM_HOSTNAME}-OSSIM_${OSSIM_VERSION}-alienvault-mysql-all-dbs.sql.gz

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.